What is MySQL TRUNCATE command used for?

As the name explains, it is used to remove all the record from the MySQL table.


Truncate table table_name;


mysql> Truncate table student;
Query OK, 0 rows affected (0.18 sec)

The query above deleted all the records from the ‘Student’ table. We can observe as MySQL returns empty set after running the following query −

mysql> select * from student;
Empty set (0.00 sec)
Samual Sam
Samual Sam

Learning faster. Every day.