Truncate Vs Delete
What is the difference between truncate and delete?
- Truncate deletes all records at once unconditionally, whereas delete can delete the records conditionally or unconditionally.
- Deleted data by truncate command can not be rolled back, whereas deleted data by delete command can be rolled back.
- Memory will be released after deletion of record by truncate command whereas memory will not be released after deletion of record by deleted command.
- Truncate is a DDL command, whereas delete is DML command.
- Trigger does not get fired in case of TRUNCATE whereas triggers get fired in case of a DELETE command.
- We can not TRUNCATE a table if table have any foreign key constraint. We need to remove the constraint then truncate the table and recreate the constraint.
No comments:
Post a Comment