Loading Data Driven Insights
Preparing your learning content.
Preparing your learning content.
A beginner-friendly guide to using TRUNCATE TABLE in SQL Server to remove all rows from a table while keeping the table structure.
On this page
Jump to a lesson section
TRUNCATE TABLE is a SQL statement used to remove all rows from a table quickly.
It removes the data inside the table, but keeps the table structure so the table can be reused again.
The basic structure is simple: write TRUNCATE TABLE, followed by the table name.
TRUNCATE TABLE table_name;
For example, this command removes all rows from the Employees table.
TRUNCATE TABLE Employees;
TRUNCATE TABLE does not use WHERE.We will use TRUNCATE TABLE to remove all rows from this Employees table.
This command removes every row from the Employees table.
TRUNCATE TABLE Employees;
After truncation, the table still exists, but the rows are gone.
Use DELETE when you need a WHERE condition. Use TRUNCATE TABLE when the entire table should be cleared.
It keeps the table structure, but it cannot filter selected rows with WHERE. Use it only when the whole table should be emptied.
SQL Roadmap Progress
Topic 14 of 111
13% complete
Next in SQL Roadmap
Continue with the next SQL topic in the recommended roadmap order.
Continue learning →