Dropping Unique constraint from MySQL table
How can I drop the "Unique Key Constraint" on a column of a MySQL table using phpMyAdmin?
Solution 1:
A unique constraint is also an index.
First use SHOW INDEX FROM tbl_name
to find out the name of the index. The name of the index is stored in the column called key_name
in the results of that query.
Then you can use DROP INDEX:
DROP INDEX index_name ON tbl_name
or the ALTER TABLE syntax:
ALTER TABLE tbl_name DROP INDEX index_name
Solution 2:
You can DROP
a unique constraint from a table using phpMyAdmin as requested as shown in the table below. A unique constraint has been placed on the Wingspan field. The name of the constraint is the same as the field name, in this instance.
Solution 3:
The indexes capable of placing a unique key constraint on a table are PRIMARY
and UNIQUE
indexes.
To remove the unique key constraint on a column but keep the index, you could remove and recreate the index with type INDEX
.
Note that it is a good idea for all tables to have an index marked PRIMARY
.
Solution 4:
To add UNIQUE constraint using phpmyadmin, go to the structure of that table and find below and click that,
To remove the UNIQUE constraint, same way, go to the structure and scroll down till Indexes Tab and find below and click drop,
Hope this works.
Enjoy ;)
Solution 5:
For WAMP 3.0 : Click Structure Below Add 1 Column you will see '- Indexes' Click -Indexes and drop whichever index you want.