All three commands make data disappear, and all three can ruin your day if you pick the wrong one. The difference is in what they remove and how :
DELETE removes some or all rows , one by one.
TRUNCATE removes all rows at once, keeping the empty table.
DROP removes the table itself : rows, structure, indexes and all.
DELETE FROM sessions WHERE expires_at < now ( ) ; -- some rows TRUNCATE TABLE staging_import ; -- all rows, table stays DROP TABLE old_reports ; -- the table is gone
Enter fullscreen mode
Exit fullscreen mode
Side by side
DELETE TRUNCATE DROP
Removes Rows matching WHERE All rows Table and its data
Table structure Kept Kept Removed
WHERE clause Yes No No
Speed on big tables Slow, row by row Fast Fast
Row triggers fire Yes No No
Rollback Yes, in a transaction PostgreSQL, SQL Server: yes. MySQL, Oracle: no PostgreSQL, SQL Server: yes.…