Vous êtes sur la page 1sur 1

SQL Server interview questions and answers: - Difference between 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 Filters Truncate

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. at a time. Pages are 8 KB units which stores row data. procedure Performance Triggers Slower, as delete happens Truncate is faster as compared to delete as row wise. data is removed in pages. Triggers are executed in In truncate triggers are disabled. delete as the data is removed row wise. In delete the identity value is In truncate the identity is reset back to zero. retained.

Identity

The above question and the answer is taken from the SQL Server interview question book written by Shivprasad Koirala. Heres an awesome article, it covers 50 important SQL Server interview question. Heres an awesome video on Difference between Sub Query and co-related queries ?( SQL Server interview questions )

Vous aimerez peut-être aussi