I have a table with some data. This table has 1:N relation to some other tables and this other tables have also some 1: N relations.
I need to recreate the table with some changes.So far I've created a table with the same structure and copied data into it from the original table.My intention is to delete the or开发者_开发技巧iginal table and rename the new table to match the orginal name.
The problem is I cannot delete the original table because of the child records.
How to solve this problem ? Or is there any other way for this kind of task ?
You first need to drop the constraints from the child table with something like:
ALTER TABLE <your child table> DROP CONSTRAINT <your constraint>;
Look for the constraints on the child table pointing to the parent.
Then you should be able to drop your old parent table, rename, and re-add the constraints.
精彩评论