ryber
ryber

Reputation: 4555

Dropping FK Constraint On Something Other Than Name

I have a application database where there are lots of different copies of the schema on different servers (developers, stag, prod etc)

I have two tables that were related by a FK contraint like

Foo.fk = Bar.Id

I want to drop the Bar table. but I don't want to drop the Foo.fk column. I just want to remove the constraint from it.

The problem is that the script that originally created the constraint made it different in different environments. Is there a way to remove the constraint by some way other than drop by name?

Upvotes: 2

Views: 87

Answers (1)

user330315
user330315

Reputation:

No need to drop the constraint manually:

DROP TABLE bar CASCADE CONSTRAINTS;

will drop the bar table and any constraint referencing it.

Upvotes: 5

Related Questions