Database Journal just published a very useful script to
Truncate Database by Shane Lively. What I found also interesting there – that you can disable constraints/triggers for certain table using
ALTER TABLE MyTable NOCHECK CONSTRAINT ALL and
ALTER TABLE MyTable DISABLE TRIGGER ALL, and reset identity seed using
DBCC CHECKIDENT ("MyTable", RESEED, 0). But what I don’t understand – why author uses
Delete instead of
Truncate, which is faster and more efficient?
Why delete instead of truncate? Perhaps because truncate requires greater permissions than delete. "The minimum permission required is ALTER on table_name. TRUNCATE TABLE permissions default to the table owner, members of the sysadmin fixed server role, and the db_owner and db_ddladmin fixed database roles, and are not transferable."
ReplyDeleteYes, agree
ReplyDelete