DELETE vs TRUNCATE
suggest changeTRUNCATE 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.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents