This is one of most frequently asked question in Oracle interviews.
I tried to put all the differences i know,you are welcome to put your thoughts and comment on that
Delete
- It is a DML statement
- Can Rollback
- Can delete selective records
- It fires database triggers.
- It does not requires disabling of referential constraints
- Deletes perform normal DML. That is, they take locks on rows, they generate redo (lots of it), and they require segments in the UNDO tablespace. Deletes clear records out of blocks carefully. If a mistake is made a rollback can be issued to restore the records prior to a commit. A delete does not relinquish segment space thus a table in which all records have been deletedretains all of its original blocks.
Truncate
- It is a DDL statement
- Can’t Rollback
- Can’t delete selective records.It will delete all the records in table
- Doesn't fire database triggers
- It requires disabling of referential constraints
- Truncate moves the High Water Mark of the table back to zero.No row-level locks are taken,no redo or rollback is generated.
-- To remove Control M characters
ReplyDeletevi filename
Press escape key
:%s/CTRL-V CTRL-M//g
Umesh Joshi (Singapore)