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 is self join in sql server joins?
Explain features and concepts of analysis services?
What are two difference between sql azure and azure tables?
What is the largest component inside a field?
What are the new scripting capabilities of ssms? : sql server management studio
Define tool Manage Statistics in SQL Server 2000 query ?
What command do we use to rename a database?
How to identify current user in ssrs report?
How to use old values to define new values in update statements in ms sql server?
How to list all login names on the ms sql server?
Explain trigger classes i.e. Instead of and after trigger?
What are the different types of replication you can set up in sql server?
Does the order of columns in update statements matter?
Does sql server 2000 clustering support load balancing?
How to check table values in sql server?