Monday, 25 April 2016

DROP vs. TRUNCATE vs. DELETE


DROP TABLE
  • Deletes Table structure  + Data
  • Invalidates the dependent objects
  • Drops the indexes

TRUNCATE and DELETE
  • Deletes only data

TRUNCATE vs. DELETE
  • TRUNCATE performs an automatic commit and cannot be rolled back (It 's a DDL) but after DELETE, you can commit / rollback changes (It' s DML) 
  • Trigger is fired when DELETE is used, but not in case of TRUNCATE
  • Condition (WHERE clause) can be used with DELETE but not with TRUNCATE
  • TRUNCATE is faster than DELETE

Before deleting using DELETE, all data is copied to Rollback Tablespace but in case of TRUNCATE there is no extra copy operation, so TRUNCATE is faster than DELETE

No comments:

Post a Comment

Note: only a member of this blog may post a comment.