Wednesday, May 20, 2009

MySQL:Set up unique key ignoring duplicates

For many of you who might be having trouble setting up a unique key on
a table containing duplicates, here's the key

mysql> ALTER IGNORE TABLE table_name ADD UNIQUE(column_name)

Please note the keyword IGNORE in the above statement. That does the
work forcefully.