- Instant help with your Sql coding problems

Delete all records from a table in MySQL

Question:
How to delete all records from a table in MySQL?
Answer:
TRUNCATE mytable;
Description:

If you want to remove all rows in a table then you can use the TRUNCATE statement which is much faster than DELETE .

TRUNCATE TABLE empties a table completely. It requires the DROP privilege. Logically, TRUNCATE TABLE is similar to a DELETE statement that deletes all rows, or a sequence of DROP TABLE and CREATE TABLE statements.

To achieve high performance, TRUNCATE TABLE bypasses the DML method of deleting data. Thus, it does not cause ON DELETE triggers to fire, it cannot be performed for InnoDB tables with parent-child foreign key relationships, and it cannot be rolled back like a DML operation.

Share "How to delete all records from a table in MySQL?"
Tags:
delete all rows from table, truncate table, fast delete
Technical term:
Delete all records from a table in MySQL