TRUNCATE TABLE Command in SQL – DDL Statements



TRUNCATE TABLE Command – DDL Statements

The TRUNCATE TABLE command used to delete all the rows/records from entire table.
The TRUNCATE command also remove the index from columns.

If we want to delete the table structure then use DROP Command. The TRUNCATE TABLE Command only delete the data from the table not the structure of table from database.

The TRUNCATE TABLE command cannot delete any data that would violate FOREIGN KEY or any other constraints.

TRUNCATE TABLE Command Syntax:

TRUNCATE  TABLE  tablename

tablename is the name of table to be truncated.

Example of TRUNCATE TABLE Command:

TRUNCATE  TABLE  Student

Delete all the records from Student table when execute above truncate command.

 

Leave a Reply

Your email address will not be published. Required fields are marked *