MySQL - Make an existing Field Unique -


i have existing table field should unique not. know because entry made table had same value another, existing, entry , caused problems.

how make field accept unique values?

alter ignore table mytbl add unique (columnname); 

for mysql 5.7.4 or later:

alter table mytbl add unique (columnname); 

as of mysql 5.7.4, ignore clause alter table removed , use produces error.

so, make sure remove duplicate entries first ignore keyword no longer supported.

reference


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -