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.
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.
Learning SQL in order?
Use the roadmap to follow each SQL topic step by step, from relational database basics to advanced query techniques.
Back to SQL RoadmapRelated lessons
ALTER TABLE
A beginner-friendly guide to ALTER TABLE in SQL, including how to add, change, and remove columns from an existing table.
CREATE TABLE
A beginner-friendly guide to the SQL CREATE TABLE statement, including table planning, column names, data types, and a SQL Server-friendly example.
DELETE
A beginner-friendly guide to the SQL DELETE statement, with SQL Server-friendly examples for removing rows from a table safely.