limited time offer

What is truncate command in sql ?

The TRUNCATE TABLE command deletes the data inside a table, but not the table itself without removing its structure. Example:


The SQL TRUNCATE TABLE statement is used to remove all records from a table. It performs the same function as a DELETE statement without a WHERE clause. You may not be able to roll back the TRUNCATE TABLE statement in all SQL databases.

Truncate is all or nothing, you can not use WHERE clause with Truncate. With DELETE you can use WHERE clause. Below statement will return error:

TRUNCATE TABLE sys.Members where membership_number = 2;

Truncate is faster than DELETE command.