Zolf
asked on
Cannot truncate table because it is being referenced by a FOREIGN KEY constraint
Hello there,
How can I truncate a table which has foreign key constraints. I am in development and I need to truncate the tables.is there some easy way to this.
cheers
Zolf
How can I truncate a table which has foreign key constraints. I am in development and I need to truncate the tables.is there some easy way to this.
cheers
Zolf
ASKER
but the issue is that that delete will not start the pk from 1. I want the pk to be reset too which truncate does it for you. by the way what do you mean "the records being deleted do not cause any RI issue."
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you want to persist with truncate, then you have to drop each FK, perform the truncate, then recreate the FK
Kelvin
Kelvin
Note that the process to drop/recreate of constraint can entirely be scripted as well as the truncate itself. You can generate entirely the drop/recreate of constraints.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
Kelvin