Reputation: 105
In SQL developer, when PRIMARY KEY is added like this:
PRIMARY KEY("ID")
In CONSTRAINT is generated with a name like "SYS006321". I need to change this name.
I tried to ADD:
CONSTRAINT TABLE_NAME_PK PRIMARY ("ID")
but I can't because can be only one PRIMARY KEY. This PRIMARY KEY is used in FOREIGN KEYs in others tables. So if i want to drop this PRIMARY KEY and after that add CONSTRAINT. I have to drop with cascade, so i lose references in FOREIGN KEY. What should I do?
Upvotes: 0
Views: 421
Reputation: 23361
If this is Oracle you can rename a constraint like this:
ALTER TABLE yourTable RENAME CONSTRAINT SYS006321 TO yourNewName;
Upvotes: 1
Reputation: 31775
First drop the foreign keys that point to the Primary Key.
Then drop the Primary Key.
Then re-create the primary key with the name you want.
Then re-create the foreign keys.
Upvotes: 1