0

I have several tables with primary keys. I did not give these primary keys constraints any name. Is it possible to give them name now and how? I am using MySQL 5.7.

ruslan5t
  • 257
  • 3
  • 16

1 Answers1

0

Try this

ALTER TABLE `mytable`
DROP PRIMARY KEY,
CHANGE COLUMN oldname newname INT(11) DEFAULT NULL,
ADD CONSTRAINT `mytable_newname_pk` PRIMARY KEY (`newname`)