What is the difference between TRUNCATE and DELETE in T-SQL?

1 Answers
Answered by suresh

What is the difference between TRUNCATE and DELETE in T-SQL?

In T-SQL, TRUNCATE and DELETE are both used to remove data from a table, but they have some key differences:

  • TRUNCATE: TRUNCATE is a DDL (Data Definition Language) command that removes all rows from a table, but it does not log individual row deletions. It is a faster operation than DELETE because it simply deallocates the data pages used by the table.
  • DELETE: DELETE is a DML (Data Manipulation Language) command that removes one or more rows from a table based on a certain condition. DELETE logs each row deletion, which can make it slower than TRUNCATE, especially for large tables.

In summary, TRUNCATE is faster and deallocates data pages, while DELETE logs each row deletion and is slower. Choosing between TRUNCATE and DELETE depends on the specific requirements of your data removal operation.

Answer for Question: What is the difference between TRUNCATE and DELETE in T-SQL?