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 the differences in Clustering in SQL Server 2005 and 2008 or 2008 R2?
How to modify existing triggers using "alter trigger"?
What is sub-query in sql server? Explain its properties.
What are distributed partitioned views?
what are different types of backups available in sql server? : Sql server database administration
What is the osql utility?
What are the advantages of passing name-value pairs as parameters?
What is for xml in sql server?
How do I save a stored procedure in sql server?
What are the lambda triggers?
Explain the types of indexes.
How to get the definition of a trigger back?
Can you import Microsoft Excel data to SSRS?
How to find the source of a table in sql server?
What is the Disadvantage of indexed sequential file.