Beginner

703. TRUNCATE TABLE

Learn how to quickly remove all records from a table while keeping its structure.

📘 Lesson 703 of 728 ⏱ 6 min 🎯 Beginner

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.

SQL
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.

Have you finished this lesson?

Introduction to SQL – All Lessons