This article discusses how to delete all the rows of a table using the TRUNCATE clause.
In the previous article, we learned how to delete data using the DELETE statement. However, if we intend to delete all the rows from a table then a faster route is to use the TRUNCATE statement. Generally, we don’t want to delete all the table rows except in the case of temporary tables. The TRUNCATE statement drops a table and recreates it for faster processing. MySQL doesn’t count the number of rows affected and may show the count to be zero or non-zero, but the number doesn’t reflect the actual number of rows affected.
Example Syntax :
TRUNCATE table;
Execute the following query to remove all the rows from the table:
TRUNCATE Actors;

Note that TRUNCATE doesn’t work with locking or transactions and is the equivalent of DELETE when used with InnoDB tables. InnoDB refers to a particular type of database engine and is covered in the lessons ahead.