Brian Bruman Brian Bruman -4 years ago 90
MySQL Question

Renaming a Unique Key Name MySQL

I had a column that had a

UNIQUE KEY
ExtendedOrderID
.

I renamed this column to
OrderLineItemID
.

Still, when I go to
SHOW CREATE TABLE
it is stating

. . .
UNIQUE KEY `ExtendedOrderID` (`OrderLineItemID`)
. . . ) ENGINE=InnoDB . . .


Showing my original column name.

Now, I don't think this is affecting anything, since it's still pointing to the new properly named column
OrderLineItemID
, but how do I completely remove
ExtendedOrderID
from the table and rename it to show properly

UNIQUE KEY `OrderLineItemID` (`OrderLineItemID`)

Answer Source

You have to drop it and then recreate it again with the new name:

alter table yourTableName drop index ExtendedOrderID;

create unique index OrderLineItemID on yourTableName (OrderLineItemID);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download