Drop unique constraint in MySQL

02 / Jul / 2010 by Uday Pratap Singh 1 comments

Recently in my Grails project I mentioned a domain field as unique in constraints. So the table automatically created also had the same constraint, but as the requirement changed the field was not supposed to be unique. Now we need to remove that constraint from the database table as well. The trick in MySQL is that it stores the unique constraint fields as an index and not like other constraints so we cannot do the drop constraint for a unique constraint. The simple solution for this is to drop the index like this:

alter table person drop index address

It worked.

Hope it helps
Uday Pratap Singh
uday@intelligrape.com

FOUND THIS USEFUL? SHARE IT

comments (1 “Drop unique constraint in MySQL”)

Leave a Reply to idris alhaji adamu Cancel reply

Your email address will not be published. Required fields are marked *