setting a collumn to be unique in existing table

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
mcyi2mr3 [ So, 22 Oktober 2006 18:01 ] [ ID #1509262 ]

Re: setting a collumn to be unique in existing table

also the syntax to unset this would also be useful. thanks
mcyi2mr3 [ So, 22 Oktober 2006 18:02 ] [ ID #1509263 ]

Re: setting a collumn to be unique in existing table

mcyi2mr3 [at] 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
zac.carey [ So, 22 Oktober 2006 18:45 ] [ ID #1509264 ]
Datenbanken » mailing.database.mysql » setting a collumn to be unique in existing table

Vorheriges Thema: Ann: A web based tool for sql to cgi conversion
Nächstes Thema: Foreign Key Problem