TRUNCATE

Use this MySQL statement to delete the contents of a table rapidly. It's similar to the DELETE statement in that it will delete all of the data contained in a given table.

Syntax

Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

TRUNCATE [TABLE] table

Explanation

Use this statement to delete the contents of a table rapidly. It's similar to the DELETE statement in that it will delete all of the data contained in a given table. The TRUNCATE statement does its job by dropping the table and then recreating it without data. As a result, it does not report the number of rows deleted. Another drawback is that the value for an AUTO_INCREMENT column will be lost along with the data. The statement does preserve file partitions and partition parameters if the table was originally partitioned.

This statement is not transaction-safe. As of version 5.1.16 of MySQL, DROP privileges are required for this statement. Previously, DELETE privileges were required.