By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

How i removed a PRIMARY KEY from a table column

How i finally managed to do something really simple, remove a PRIMARY KEY from a MySQL table column.

Edited: 2014-12-15 15:01

By. BlueBoden

I was trying to remove a PRIMARY KEY from a column in a MySQL table, and followed the instructions that i found online – the only problem was, that this would result in an error.

Error 1091 (42000): Can't drop 'primary' check that column/key exists

The instructions that i was able to find, all told to drop the PRIMARY KEY, without specifying the column of the table, which i found rather confusing. But in any case, entering the command below did not work.

ALTER TABLE Persons DROP PRIMARY KEY;

How i removed a PRIMARY KEY

I then thought of trying something else, that was, to drop the index from the column. So i went and typed the following command in the terminal:

ALTER TABLE tagged DROP INDEX page_id;

This resulted in a success, and by doing this, i even retained the data in the column, so i did not have to repost everything to the table.

I tried the same command some time after, on another table, but this time it was the other way around, and the DROP PRIMARY KEY that worked.

ALTER TABLE Persons DROP PRIMARY KEY;