When working with MySQL, you may need to remove all rows from a table while keeping its structure intact. MySQL provides two main ways to achieve this: using the DELETE
statement or the TRUNCATE
command. The method you choose depends on whether you want to reset the table's auto-increment counter. This tutorial explains how to delete all rows from a table in MySQL.
1. Delete all rows
To delete all rows from a table without resetting the auto-increment value, use:
DELETE FROM table_name;
2. Delete all rows and reset auto-increment
If you want to remove all records and reset the auto-increment value, use:
TRUNCATE table_name;
Leave a Comment
Cancel reply