setting a collumn to be unique in existing table

setting a collumn to be unique in existing table

am 22.10.2006 18:01:06 von mcyi2mr3

hi all

ive been looking on the mysql site but i cant find the syntax to set a
collumn in an existing table to be unique.

could someone please give an example of how to do this.

i believe it goes something like: alter table tblname add unique
colname

but i could be wrong

Re: setting a collumn to be unique in existing table

am 22.10.2006 18:02:21 von mcyi2mr3

also the syntax to unset this would also be useful. thanks

Re: setting a collumn to be unique in existing table

am 22.10.2006 18:45:30 von zac.carey

mcyi2mr3@googlemail.com wrote:
> also the syntax to unset this would also be useful. thanks

ALTER TABLE `my_table` ADD UNIQUE (`my_field`)

ALTER TABLE `my_table` DROP INDEX `my_field_index`

have a look at phpmyadmin