Can you tell me the difference between DELETE & TRUNCATE
commands?

Answer Posted / afzal_aziz

Truncate:

- deallocates the data pages in a table and only this
deallocation is stored in transaction log

- aquires only table and page locks for the whole table.
since no row locks are used less memory is required (lock
is a pure memory object)

- resets identity column if there is one

- removes ALL pages. NO empty pages are left behind in a
table

- fast(er)

- doesn't fire delete triggers

Delete:

- removes one row at the time and every deleted row is
stored in the transaction log

- aquires table and/or page and row locks for the whole
table

- leaves identity column alone

- can leave empty pages in a table since empty page
removal requires a table lock which doesn't necessarily
happen

- slow(er)

- fires delete triggers


http://weblogs.sqlteam.com/mladenp/archive/2007/10/03/SQL-
Server-Why-is-TRUNCATE-TABLE-a-DDL-and-not.aspx

Is This Answer Correct ?    8 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I track the changes or identify the latest insert-update-delete from a table?

759


How to count duplicated values in a column in ms sql server?

735


What is difference between views and stored procedures?

761


Explain error handling in ssis?

790


What is the parse query button used for?

824


How to use “drop” keyword in sql server and give an example?

905


Which table keeps information about stored procedures?

754


How to delete existing rows in a table?

810


Do you know what are various aggregate functions that are available?

749


What are the advantages of sql azure?

134


What do you mean by cardinality?

682


Explain what is row_number function?

803


What is exporting and importing utility?

809


Is t sql the same as sql server?

771


What is sql server database?

732