Difference between truncate and delete command in SQL
This is an important point to understand before using truncate or delete on the production environment, or writing any script which purges data from tables.
1. truncate is fast delete is slow.
2. truncate doesn't do logging delete logs on a per-row basis.
3. rollback is possible with delete not with truncate until specifically supported by the vendor.
4. truncate doesn't fire trigger, delete does.
5. Don't delete, truncate it when it comes to purging tables.
6. truncate reset identity column in the table if any, delete doesn't.
7. truncate is DDL while delete is DML (use this when you are writing exam)
8. truncate doesn't support where clause, delete does.
Post a Comment