Ticker

6/recent/ticker-posts

Header Ads Widget

Responsive Advertisement

SQL TRUNCATE TABLE

 


SQL TRUNCATE TABLE

The SQL TRUNCATE TABLE command is used to delete complete data from an existing table.

You can also use DROP TABLE command to delete complete table but it would remove complete table structure form the database and you would need to re-create this table once again if you wish you store some data.

 

Syntax:

TRUNCATE TABLE table_name;

 

Example:

Consider the CUSTOMERS table having the following records:

+----+-------------+------+-----------------+---------------+

| ID  | NAME      | AGE  | ADDRESS      | SALARY       |

+----+-------------+------+-----------------+---------------+

| 1    | Ramesh   | 32    | Ahmedabad   | 2000.00      |

| 2    | Ramesh   | 25    | Delhi                | 1500.00      |

| 3    | kaushik   | 23    | Kota                 | 2000.00      |

| 4    | Chaitali    | 25   | Mumbai          | 6500.00       |

| 5    | Chaitali    | 27    | Bhopal            | 8500.00       |

| 6    | Komal      | 22    | MP                   | 4500.00       |

| 7    | Muffy       | 24    | Indore            | 10000.00     |

+----+-------------+------+-----------------+---------------+

 

Following is the example to truncate:

SQL > TRUNCATE TABLE CUSTOMERS;

 

Now, CUSTOMERS table is truncated and following would be the output from SELECT statement:

SQL> SELECT * FROM CUSTOMERS;

Empty set (0.00 sec)

 

 




आशा करते है कि हमारे द्वारा लिखी हुई इस Post को आप Like, Share and Comment करेंगे | और हमें Comment करके बताये की आपको ये Post कैसी लगी | इसी तरह की Post और News पाने के लिए हमारे सभी Social Media Channels को रेगुलर Follow करे| 


Thanks
Amar Digital World
(Always Ready To Digital Serve)

Post a Comment

0 Comments