TRUNCATE TABLE is a Data Definition Language (DDL) command that removes every row from a table without deleting the table itself. The table structure, column definitions, and constraints remain available for future use.
When all records need to be removed before loading fresh data, TRUNCATE TABLE is much faster than deleting rows individually.
A staging table receives daily sales data. Before importing today's file, yesterday's records are removed using TRUNCATE TABLE.
TRUNCATE TABLE Employees;
Data warehouses, ETL processes, reporting systems, and staging environments frequently use TRUNCATE TABLE before loading new data.
- Removes all rows.
- Keeps the table structure.
- Faster than DELETE for entire tables.
- Cannot use a WHERE clause.
- Often resets identity values.
- Useful for staging tables.
- It is a DDL command.
What is the difference between DELETE and TRUNCATE?
DELETE removes rows individually and supports a WHERE clause, while TRUNCATE removes all rows quickly without a WHERE clause.
Does TRUNCATE delete the table?
No. It removes only the data while keeping the table structure.