TRUNCATE
모든 Row를 지우는 경우
Auto-Increment reset
Roll back 불가
Cannot be used with a where clause
TRUNCATE TABLE your_table_name;
DELETE
Removes one or more rows from a table based on a specified condition.
Is slower than TRUNCATE, especially for large tables, as it processes each row individually.
Can be rolled back within a transaction, allowing for data recovery in case of mistakes.
Activates triggers if they are defined on the table.
Can be used with a WHERE clause to delete specific rows.
DELETE FROM your_table_name WHERE condition;
or
BEGIN TRANSACTION;
DELETE FROM table1;
DELETE FROM table2;
-- Repeat for other tables
COMMIT;