user256034
user256034

Reputation: 4369

Recreate table with data and 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 original 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 ?

Upvotes: 1

Views: 209

Answers (1)

Gerrat
Gerrat

Reputation: 29740

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.

Upvotes: 1

Related Questions