Pawan Sinha
Pawan Sinha

Reputation: 23

Can I drop the primary key without dropping the referenced foreign key?

I wanted to drop the primary key without dropping the referenced foreign key. But the foreign key is disabled.

Later I again want to create a primary key with the same name and enable the foreign key.

Upvotes: 0

Views: 1035

Answers (1)

APC
APC

Reputation: 146239

I wanted to drop the primary key without dropping the referenced foreign key

Can't be done. The presence of a referencing foreign key - disabled or otherwise - prevents the dropping of a primary key.

Your options are:

  1. disable the primary key instead; or
  2. drop and subsequently re-create the foreign key as well.

Which option suits better will depend on your motivations for dropping the primary key in the first place.

Upvotes: 2

Related Questions