How to drop unique in MySQL?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
In MySQL, a UNIQUE constraint is enforced through a unique index. That means removing uniqueness is usually a matter of dropping the underlying index by name. The important part is identifying the correct index first, especially when the constraint was created automatically or across multiple columns.
Find the Name of the Unique Index
Before dropping anything, inspect the table definition. The easiest way is SHOW CREATE TABLE.
Example output might contain something like:
In this case, the unique index is named email. You can also list indexes directly:
That is often clearer when a table has several indexes.
Drop the Unique Constraint With ALTER TABLE
Once you know the index name, drop it with ALTER TABLE ... DROP INDEX.
After that statement succeeds, the column is no longer protected by uniqueness, and duplicate values can be inserted.
In MySQL, this is the normal way to remove a unique constraint. There is no separate DROP CONSTRAINT syntax for ordinary unique indexes like there is in some other database systems.
Example With a Composite Unique Constraint
A unique constraint can span more than one column. For example:
To remove it:
After dropping the index, the same student and course pair can appear more than once.
Be Careful With Automatically Chosen Names
If you created the table through a migration tool or ORM, the unique index name may not match the column name. That is why guessing can waste time. Always inspect the actual schema first.
For example, a migration tool might create:
Then the correct command would be:
Using the column name by mistake would fail because MySQL drops indexes by index name, not by column reference.
Verify the Result
After the change, confirm the unique index is gone:
Or inspect the full table definition again:
Verification matters because some tables have both a unique index and a separate nonunique index on related columns, and you want to be sure you removed the intended one.
Consider the Data Model Before Removing Uniqueness
Dropping a unique constraint is easy technically, but it changes the rules of the table. If the application previously assumed every email, username, or external ID was unique, queries and business logic can break.
Typical consequences include:
- duplicate user accounts
- ambiguous lookup queries
- failed assumptions in joins
- broken upsert logic based on uniqueness
If duplicates will now be allowed, it is worth reviewing validation code and any reports or APIs that assumed uniqueness.
Replacing the Constraint Instead of Just Dropping It
Sometimes the real requirement is not "remove uniqueness completely" but "change which columns must be unique." In that case, drop the old unique index and create a new one.
That pattern is common in multi-tenant applications where a field should be unique only within a tenant or organization.
Common Pitfalls
The biggest mistake is trying to use DROP CONSTRAINT syntax copied from another database engine. In MySQL, ordinary unique constraints are dropped as indexes. Another common issue is guessing the index name instead of checking SHOW CREATE TABLE or SHOW INDEX. Developers also remove uniqueness without realizing application logic depends on it. Composite unique indexes deserve extra care because dropping them changes rules across several columns at once. Finally, schema changes on large production tables should be planned carefully because index changes can still affect performance and deployment timing.
Summary
- In MySQL, a
UNIQUEconstraint is usually enforced by a unique index. - Find the real index name with
SHOW CREATE TABLEorSHOW INDEX. - Remove it with
ALTER TABLE table_name DROP INDEX index_name. - Composite unique constraints are dropped the same way.
- Verify the schema after the change.
- Review application logic before allowing duplicate values.
Related reading
- How to enable batch inserts with Hibernate and Spring Boot
- How to enable MySQL Query Log?
- How to enable pdo_mysql in the php docker image
- How to enable streaming replication in PostgreSQL running in kubernetes pods?
- How to ensure data consistency in Cassandra on different tables?
- How to ensure the table get scanned daily as the table size growing
- How to escape apostrophe a single quote in MySQL?
- How to escape single quotes in Unload

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.