How can I drop the "Unique Key Constraint" on a column of a MySQL table using phpMyAdmin?
-
Look at http://forums.mysql.com/read.php?98,70887,70974#msg-70974 – James Black Aug 15 '10 at 14:13
10 Answers
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

- 811,555
- 193
- 1,581
- 1,452
-
1Sorry sir i had tried it before raising the question ,but its not working – Ankur Mukherjee Aug 15 '10 at 14:26
-
@Ankur Mukherjee: I forgot to mention: You have to change tbl_name and index_name to the name of your actual table and the name of the actual index, respectively. You can see the names in MySQL Query Browser. You can also do `SHOW CREATE TABLE tbl_name`. – Mark Byers Aug 15 '10 at 14:33
-
Error Message:"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(player_id,year,tournament)' at line 1" – Ankur Mukherjee Aug 15 '10 at 14:56
-
@Ankur Mukherjee: That's because you're not using the name of the index. The name of the index is defined when you create the index. Find out the name of the index and use the index name in the DROP INDEX statement. – Mark Byers Aug 15 '10 at 14:59
-
You can also use `SHOW INDEX FROM tbl_name` to show information about all indexes on a table, including the name of the index. – Mark Byers Aug 15 '10 at 15:00
-
INDEX name refers to the name of the column on which "UNIQUE KEY" constraint is specified isn't it sir? – Ankur Mukherjee Aug 15 '10 at 15:01
-
@Ankur Mukherjee: No, that is not correct. The index name might or might not be the same as the column name. Usually it is not. – Mark Byers Aug 15 '10 at 15:03
-
so there is no way of just removing the unique constraint of a column?(other than removing index) – Ankur Mukherjee Aug 15 '10 at 15:04
-
1@Ankur Mukherjee: The way I have suggested is in my opinion the best way to do it. – Mark Byers Aug 15 '10 at 15:33
-
1I read somewhere in the question **using phpMyAdmin**... The answer provided by @systemovich should be marked as the accepted one. – Pere Sep 16 '14 at 14:16
-
-
-
@MarkByers Hi Sir, Do you have a suggestion for reading on DDL constraints and unique keys? Its killing my interview-readyness – chrips Aug 08 '19 at 19:27
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.

- 5,407
- 10
- 43
- 78
-
35It is important to note that the indexes section is collapsed by default, and is expanded by a small, subtle link in 12px font where the section is in the screenshot. But thanks to you, I found it. Bless your face. +1 – Jacklynn May 25 '13 at 17:39
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
.

- 114,488
- 30
- 148
- 167
-
4Upvoted because @thomasrutter has touched on the fact that removing a unique constraint **may adversely affect query performance** - and this can be mitigated by replacing the `UNIQUE` index with a regular `INDEX`. – Alex Apr 18 '14 at 16:17
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 ;)

- 4,668
- 32
- 24
If you want to remove unique constraints from MySQL database table, use alter table with drop index.
Example:
CREATE TABLE unique_constraints (
unid INT,
activity_name VARCHAR(100),
CONSTRAINT activty_uqniue UNIQUE (activity_name),
PRIMARY KEY (unid)
);
ALTER TABLE unique_constraints
DROP INDEX activty_uqniue;
Where activty_uqniue is UNIQUE constraint for activity_name column.

- 163
- 1
- 17

- 217
- 2
- 3
For WAMP 3.0 : Click Structure Below Add 1 Column you will see '- Indexes' Click -Indexes and drop whichever index you want.

- 21
- 1
The constraint could be removed with syntax:
As of MySQL 8.0.19, ALTER TABLE permits more general (and SQL standard) syntax for dropping and altering existing constraints of any type, where the constraint type is determined from the constraint name:
ALTER TABLE tbl_name DROP CONSTRAINT symbol;
Example:
CREATE TABLE tab(id INT, CONSTRAINT unq_tab_id UNIQUE(id));
-- checking constraint name if autogenerated
SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME = 'tab';
-- dropping constraint
ALTER TABLE tab DROP CONSTRAINT unq_tab_id;

- 1
- 1

- 162,964
- 23
- 234
- 275
This might help:
Inside your sql terminal
FIRST STEP:
SHOW INDEX FROM {YOUR_TABLE_NAME}
SECOND STEP:
SHOW INDEX FROM {YOUR_TABLE_NAME} WHERE Column_name='ACTUAL_COLUMN_NAME_YOU_GOT_FROM_FIRST_STEP_OUTPUT'
THIRD STEP:
ORIGINAL_KEY_NAME_VALUE = SECOND_STEP_RESPONSE["Key_name"]
FOURTH STEP:
ALTER TABLE {YOUR_TABLE_NAME} DROP INDEX ${ORIGINAL_KEY_NAME_VALUE}

- 475
- 5
- 10
while dropping unique key we use index
ALTER TABLE tbl
DROP INDEX unique_address;

- 1,319
- 9
- 18
my table name is buyers which has a unique constraint column emp_id now iam going to drop the emp_id
step 1: exec sp_helpindex buyers, see the image file
step 2: copy the index address
step3: alter table buyers drop constraint [UQ__buyers__1299A860D9793F2E] alter table buyers drop column emp_id
note:
Blockquote
instead of buyers change it to your table name :)
Blockquote
thats all column name emp_id with constraints is dropped!

- 9,270
- 3
- 27
- 45

- 7
- 2