Some times we may need to change table schema but when there are Foreign Key constraints in any column of that table it won’t allow to change anything.
We can Disable Fk Constraints check while updating table, and later can enable them after we finish updating.
TO Disable all Fk check on a Table : we can use
ALTER TABLE MyTableName NOCHECK CONSTRAINT ALL
We can enable them back as :
ALTER TABLE MyTableName CHECK CONSTRAINT ALL
NB: You can also disable individual Fk in a table.
Warning: Your DB schema may become invalid after change! We have to be sure what we are changing (Schema/Data Change) and what effect it will make on DB.