1 Answers
- DELETE is DML, TRUNCATE is DDL statement
- TRUNCATE is much faster than DELETE Reason: DELETE statement copies all the records to ROLLBACK TABLESPACE and then deletes the records row by row (thats the reason you can get back all the deleted records when you use a ROLLBACK command immediately after DELTE command. where as TRUNCATE directly deletes the records without copying it to ROLLBACK TABLESPACE.
- You can’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 can’t use WHERE clause in TRUNCATE but we can use in DELETE statment.
- Delete can be applied to tables and tables inside a cluster. Truncate applies only to tables or the entire cluster
- Truncate requires an exclusive table lock, delete requires a shared table lock.
- Delete does not recover space, Truncate recovers space (unless you use the REUSE STORAGE clause)