Truncate Table

TRUNCATE TABLE is used to delete the contents of the table including space contained by the table.

The syntax for TRUNCATE is:

TRUNCATE TABLE table_name;

 

Example

Consider a Student table

StudentID Student_Name Address City
1 Nithin Bank Street Hyderabad
2 Bharath Panama Street California

 

Now Apply TRUNCATE on the table

TRUNCATE TABLE Student;

 

The data will be deleted and also space will be freed by using TRUNCATE now.

 

There is the difference between TRUNCATE and DELETE table. The DELETE TABLE statement deletes the content, not the space contained by the table but TRUNCATE deletes the content and also the Space Contained by the Table.