- TRUNCATE is similar to the DELETE with no WHERE clause.
- DELETE is a logged operation on a per row basis. This means that the deletion of each row gets logged and physically deleted. TRUNCATE is also a logged operation, but in a different way. TRUNCATE logs the deallocation of the data pages in which the data exists.
- Because of this, TRUNCATE is faster and uses fewer system and transaction log resources.
- You can DELETE any row that will not violate a constraint, while leaving the foreign key or any other contraint in place.
- You cannot TRUNCATE a table that has any foreign key constraints. You will have to remove the contraints, TRUNCATE the table, and reapply the contraints.
- TRUNCATE will reset any identity columns to the default seed value. DELETE will not do this.
- You need to be db_owner, ddl_admin, or owner of the table to be able to fire a TRUNCATE statement.
If TRUNCATE is failed - check one of those differences.
No comments:
Post a Comment