DELETE vs TRUNCATE

suggest change
TRUNCATE tableName;

This will delete all the data and reset AUTO_INCREMENT index. It’s much faster than DELETE FROM tableName on a huge dataset. It can be very useful during development/testing.

When you truncate a table SQL server doesn’t delete the data, it drops the table and recreates it, thereby deallocating the pages so there is a chance to recover the truncated data before the pages where overwritten. (The space cannot immediately be recouped for innodb_file_per_table=OFF.)

Feedback about page:

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



Table Of Contents