TRUNCATE — Remove All Data Quickly

The TRUNCATE statement is used to quickly remove all rows from a table.
It is faster than DELETE because it doesn't log individual row deletions.

TRUNCATE is useful when you want to empty a table completely, but keep the table structure.


Syntax

TRUNCATE TABLE table_name;

Example: Truncate Employees Table

TRUNCATE TABLE employees;

This removes all rows from the employees table, but the table still exists and can be used.


Key Differences: TRUNCATE vs DELETE

TRUNCATEDELETE
Removes all rowsCan remove some or all rows
Faster, less loggingSlower, logs each row deletion
Cannot use WHERE clauseCan use WHERE clause

Tip

  • TRUNCATE is not reversible
  • No WHERE clause, and can’t target specific rows.
  • Use carefully when you really want to empty a table.

The TRUNCATE statement is a fast and efficient way to clear out a table completely!