MySQL DELETE vs TRUNCATE: Delete Table Data
There are two methods to delete table data.
- Delete data from a table using the DELETE statement, while keeping the table structure intact.
DELETE FROM table_name;
- Delete data in a table using the TRUNCATE TABLE statement and reset the auto-increment primary key.
TRUNCATE TABLE table_name;
Please note that the DELETE statement removes data row by row, while the TRUNCATE TABLE statement instantly deletes all data in the table, making it faster when deleting all data from a table.