HuntExams Academy logo
SQLBeginner#ddl#dml

Difference between DELETE, TRUNCATE and DROP?

Answer

DELETE removes selected rows, is logged, fires triggers and can be rolled back. TRUNCATE removes all rows quickly with minimal logging and resets identity. DROP removes the table definition itself.

Example

DELETE FROM orders WHERE status = 'cancelled'; -- filtered, rollback-able
TRUNCATE TABLE orders;  -- all rows, fast, identity reset
DROP TABLE orders;      -- table gone

Related Interview Questions

1
SQLIntermediate#joins

Explain all types of JOIN with an example.

Open
2
SQLIntermediate#joins

What is a SELF JOIN?

Open
3
SQLIntermediate#aggregates

Difference between WHERE and HAVING?

Open