DELETE vs TRUNCATE

suggest change
TRUNCATE tableName;

This removes all rows and resets the AUTO_INCREMENT counter. On a large InnoDB table it is much faster than DELETE FROM tableName.

TRUNCATE TABLE is DDL. InnoDB drops and recreates the table, which implicitly commits, so ROLLBACK cannot undo it. With innodb_file_per_table=OFF, the freed space stays inside the shared tablespace and is not returned to the operating system immediately.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents