What is MySQL TRUNCATE command used for?

MySQLMySQLi Database

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

Syntax

Truncate table table_name;

Example

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)
raja
Published on 19-Feb-2018 13:16:51
Advertisements