- TRUNCATE is a DDL command whereas DELETE is a DML command.
- TRUNCATE is much faster than DELETE. Reason:When you type DELETE.all the data get copied into the Rollback Tablespace first.then delete operation get performed.Thatswhy when you type ROLLBACK after deleting a table ,you can get back the data(The system get it for you from the Rollback Tablespace).All this process take time.But when you type TRUNCATE,it removes data directly without copying it into the Rollback Tablespace.Thatswhy TRUNCATE is faster.Once you Truncate you cann't get back the data.
- You cann't rollback in TRUNCATE but in DELETE you can rollback.TRUNCATE removes the record permanently.
- In case of TRUNCATE ,Trigger doesn't get fired.But in DML commands like DELETE .Trigger get fired.
- You cann't use conditions(WHERE clause) in TRUNCATE.But in DELETE you can write conditions using WHERE clause
- TRUNCATE command resets the High Water Mark for the table but DELETE does not. So after TRUNCATE the operations on table are much faster.
This blog contains questions generally asked in ASP.Net interviews along with their relevant answers
Friday, January 20, 2012
What is the difference between DELETE and TRUNCATE ?
Subscribe to:
Post Comments (Atom)
yes bro. the point is alrready there. Please see point no.5
ReplyDelete