Toad World® Forums

Cannot delete key


#1

I double click on an entity
I click the “keys” tab

I have two entries:
PK_CLIENTS PK_CLIENTS CLIENT_ID o
CLIENT_ID CLIENT_ID CLIENT_ID o

The first has the red key marking it as the primary key
The second has nothing under PK.

I don’t know how the second got there, perhaps a left over from changing my mind as to what atttribute would be the key? How do I delete the second? The delete button is greyed out.

When the script is generated it produces:
– Add keys for table CLIENTS

ALTER TABLE “CLIENTS” ADD CONSTRAINT “PK_CLIENTS” PRIMARY KEY (“CLIENT_ID”)
/

ALTER TABLE “CLIENTS” ADD CONSTRAINT “CLIENT_ID” UNIQUE (“CLIENT_ID”)
/

Which gives an error.

Message was edited by: cpisz_515


#2

Hi,

If I understand well, you have two keys on tab Keys. Both of them have the same attribute CLIENT_ID.
What might have happened: You added the attribute to PK (red key) and at the same time you set the attribute as Unique. Once you set an attribute as unique in TDM, an alternate key is created automatically. However, there’s no use setting a PK unique as a PK simply is unique.
So, solution: Edit the attribute and clear the Unique checkbox for the attribute. The second key (alternate key) will be automatically removed.

Regards,

Vladka