June 6th, 2008 posted by Bender Rodríguez
How to drop a unique constraint on a database table in MySQL
I have a table that was automatically created by Django during the syncdb process and now I want to alter that table to remove a unique constraint on one of the columns. To do so, you use the alter table command and the drop index option, but you will need the name of the index key. You can retrieve the key by issuing the following command:
SHOW CREATE TABLE mysql_table_name;
It shows the entire SQL code used to create the table. The alter table command would look like this:
ALTER TABLE profile_bodhiprofile DROP INDEX mysql_table_name_user_id;
"We are thoughtful, inquiring, and reflective, and we are the watchmen who guard against bad ideas in order to discover good ideas, consumer advocates of critical thinking who, through the guidelines of science, establish a mark at which to aim."
Michael Shermer