I want to set as unique a couple of fields in mysql
ex: field1 = 10 field2 = 30
I don't want duplicate for this couple of values. How do I set this in phpmyadmin?
thanks
I want to set as unique a couple of fields in mysql
ex: field1 = 10 field2 = 30
I don't want duplicate for this couple of values. How do I set this in phpmyadmin?
thanks
ALTER IGNORE TABLE mytable
ADD UNIQUE (field1 );
ALTER IGNORE TABLE mytable
ADD UNIQUE (field2 );
Or if you want a combined unique index:
ALTER IGNORE TABLE mytable
ADD UNIQUE (field1,field2 )
ALTER TABLE mytable ADD UNIQUE my_unique_index(field1,field2);
Explanation:
As of MySQL 5.7.4, the IGNORE clause for ALTER TABLE is removed and its use produces an error.
Source : http://dev.mysql.com/doc/refman/5.7/en/alter-table.html
A UNIQUE constraint contains an index definition