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
What are policy management terms?
What is the difference between Clustered and Non-Clustered Index?
What does COMMIT command do?
What is executereader?
How data can be copied from one table to another table?
What are examples of triggers?
What is repeatable read?
what do you understand by change data capture?
What is dbcc? Give few examples.
What's new in sql management studio for sql server? : sql server management studio
What is log in sql server?
What options are there to delete rows on the publisher and not on the subscriber? : sql server replication
Write a sql query to sort on different column name according to the parameters passed in the function?
What are character string data types in ms sql server?
Hi all, can any one please tell me the difference between sql server 2008 and orace 9i