Showing posts with label Delete VS. Truncate. Show all posts
Showing posts with label Delete VS. Truncate. Show all posts

Friday, June 17, 2011

Delete VS Truncate

"What is deference between Delete & Truncate ? " 

We all face this question in interview at least once in our career. Actually it is very tricky question. We have many misunderstanding regarding this two terms. After lots of searching today I found some good comparison between them. It is as per bellow.

Delete Truncate
Removes rows from a table or view. DELETE statements delete rows one at a time, logging each row in the transaction log, as well as maintaining log sequence number (LSN) information. Removes all rows from a table without logging the individual row deletions.
TRUNCATE TABLE is similar to the DELETE statement with no WHERE clause; however, TRUNCATE TABLE is faster and uses fewer system and transaction log resources.
You may use DELETE statement against a view (with some limitations). You can’t use TRUNCATE statement against a view.