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;
"A thinker sees his own actions as experiments and questions--as attempts to find out something. Success and failure are for him answers above all."
Friedrich Nietzsche