开发者

Recreate table with data and relations

开发者 https://www.devze.com 2023-03-14 14:48 出处:网络
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 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消