🧹 TRUNCATE Command in SQL

Last Updated: January 2026


The TRUNCATE command is a DDL (Data Definition Language) command used to remove all rows from a table quickly.

👉 TRUNCATE deletes data only, not the table structure.

  • Remove all records from a table
  • Reset the table to an empty state
  • Keep columns, datatypes, and constraints intact
  • Does not support WHERE clause

Hinglish Tip 🗣: Table ko empty karna ho bina delete kiye, tab TRUNCATE use hota hai.


TRUNCATE TABLE

Deletes all rows from a table.

TRUNCATE TABLE table_name;
-- or

TRUNCATE TABLE table_name IMMEDIATE;
  • IMMEDIATE option deletes the data without any rollback
  • IMMEDIATE option is not supported by all DBs
TRUNCATE TABLE employees;

After this:

  • Table structure ✅
  • Column definitions ✅
  • Table data ❌ (all rows removed)

⚠️ TRUNCATE vs DELETE vs DROP Command

  • TRUNCATE

    • Very fast
    • Removes all rows
    • Cannot use WHERE
    • Auto-committed
  • DELETE

    • Slower
    • Can remove selected rows using WHERE
    • Can be rolled back (in transactions)
  • DROP

    • Slowest
    • Permanently removes the table
    • Cannot be rolled back

⚠️ Important Characteristics of TRUNCATE

  • Resets auto-increment counters
  • Cannot filter rows
  • Cannot be rolled back in most DBs
  • Requires higher privileges than DELETE