When I try to alter a table I got this error:
#1064– You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘PRIMARY KEY (id)’ at line 1
Here is my query:
ALTER TABLE gk
ADD COLUMN id MEDIUMINT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id);
How can I resolve this?
In an
ALTER TABLEstatement, a singleADDspecification can’t add both a column and a constraint; you’ll need to put them in separate specifications:(See §13.1.6 “
ALTER TABLESyntax” in the MySQL 5.6 Reference Manual.)