Search

Monday, November 14, 2011

Difference between TRUNCATE command and DELETE Command


There are lots of differences in Delete and Truncate Command. Some are listed below:

  1. TRUNCATE is much faster than DELETE. Reason for thsi is : When you type DELETE.all the data get copied into the Rollback Tablespace first.then delete operation get performed. For this reason 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. For this reason TRUNCATE is faster. Once you Truncate you cann't get back the data.
  2. You cann't rollback in TRUNCATE but in DELETE you can rollback.
  3. TRUNCATE is a DDL command whereas DELETE is a DML command.
  4. TRUNCATE removes the record permanently. but in DELETE you can get back the data from ROLLBACK
  5. In case of TRUNCATE ,Trigger doesn't get fired.But in DML commands like DELETE .Trigger get fired.
  6. You cann't use conditions(WHERE clause) in TRUNCATE.But in DELETE you can write conditions using WHERE clause.
  7. Truncate resets identity(seed). delete will not.

No comments:

Post a Comment