What's the difference between DELETE and TRUNCATE command in SQL?

SQL
Easy
Flipkart
142.5K views

This question compares row deletion and table clearing commands. It tests knowledge of DML vs DDL operations.

Why Interviewers Ask This

The choice affects performance and transaction logs. Interviewers ask this to see if you understand the implications of each command on data and schema. It is a common pitfall for junior developers.

How to Answer This Question

Contrast DELETE (DML, row-by-row, rollbackable) with TRUNCATE (DDL, fast, resets identity). Mention WHERE clause availability. Discuss trigger firing and space reclamation.

Key Points to Cover

  • DML vs DDL
  • Rollback capability
  • Performance difference
  • Trigger behavior

Sample Answer

DELETE is a DML command that removes rows individually and can be rolled back. It fires triggers and respects WHERE clauses. TRUNCATE is a DDL command that deallocates data pages, resetting the table quickly. It cannot b…

Common Mistakes to Avoid

  • Thinking TRUNCATE deletes rows
  • Ignoring reset of auto-increment
  • Confusing permission requirements

Sound confident on this question in 5 minutes

Answer once and get a 30-second AI critique of your structure, content, and delivery. First attempt is free — no signup needed.

Try it free

Related Interview Questions

Browse all 84 SQL questionsBrowse all 131 Flipkart questions