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;
"Men are idolaters, and want something to look at and kiss and hug, or throw themselves down before; they always did, they always will; and if you don't make it of wood, you must make it of words."
Oliver Wendell Holmes, Sr.