1-- If you do not need a condition or limit the rows:
2TRUNCATE TABLE tblYourTable; -- Not Foreign key constrained
3
4-- Or
5
6SET FOREIGN_KEY_CHECKS = 0;
7
8TRUNCATE YourTable1;
9TRUNCATE YourTable2;
10
11SET FOREIGN_KEY_CHECKS = 1;
12
13-- --------------------------------------------------------
14-- Otherwise:
15DELETE FROM tblYourTable WHERE condition;
16
17-- Or
18
19DELETE FROM tblYourTable LIMIT row_count;
1/* Will delete all rows from your table. Next insert will take next auto increment id. */
2DELETE from tableName;
3/* Will delete all rows from your table but it will start from new row with 1. */
4TRUNCATE tableName;
1-- Quick, no possible rollback
2TRUNCATE TABLE my_table;
3-- With rollback
4DELETE FROM my_table;
5COMMIT;
1DELETE FROM table_name WHERE condition;
2In this statement: First, specify the table from which you delete data.
3Second, use a condition to specify which rows to delete in the WHERE clause.
4
5for example:
6DELETE FROM customers WHERE id = 1;