SQL Server Interview Questions and Answers: - Difference Between Truncate VS Delete?
SQL Server Interview Questions and Answers: - Difference Between Truncate VS Delete?
truncate VS delete?
This is the most HIT SQL Server interview question. We have lost the count of how much it has been
asked in SQL interviews.
Delete Truncate
Filters In delete we can specify a Truncate deletes all records, we can not
where clause. specify filters.
Data removal Delete removes data one row Truncate removes data by removing pages.
procedure at a time. Pages are 8 KB units which stores row data.
Performance Slower, as delete happens Truncate is faster as compared to delete as
row wise. data is removed in pages.
Triggers Triggers are executed in In truncate triggers are disabled.
delete as the data is removed
row wise.
Identity In delete the identity value is In truncate the identity is reset back to zero.
retained.
The above question and the answer is taken from the SQL Server interview question book written by
Shivprasad Koirala.
Here’s an awesome video on Difference between Sub Query and co-related queries ?( SQL Server
interview questions )