I need to change the values of a PK/FK (add 10000) on 2 tables. How do I tell the two tables involved that they should not care about referential integrity during the update, but to care after. I don't want to have to drop and recreate the relationships if I don’t have to.
4条答案
按热度按时间3yhwsihp1#
You may want to disable all the constraints in the database by executing the following command:
Then switching them back on with:
Source: Stack Overflow - Can foreign key constraints be temporarily disabled using TSQL?
3okqufwl2#
Your FK should have a "ON UPDATE CASCADE" option.
(or something like that. not 100% sure about the syntax)
And then you can just do
and the child table will be updated automatically.
n6lpvg4x3#
This link describes how to temporarily disable a contraint. I have not tested it.
4szc88ey4#
Sorry, you have to. No option.