dbTalk Databases Forums  

setting a collumn to be unique in existing table

mailing.database.mysql mailing.database.mysql


Discuss setting a collumn to be unique in existing table in the mailing.database.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
mcyi2mr3@googlemail.com
 
Posts: n/a

Default setting a collumn to be unique in existing table - 10-22-2006 , 11:01 AM






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


Reply With Quote
  #2  
Old   
mcyi2mr3@googlemail.com
 
Posts: n/a

Default Re: setting a collumn to be unique in existing table - 10-22-2006 , 11:02 AM






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


Reply With Quote
  #3  
Old   
strawberry
 
Posts: n/a

Default Re: setting a collumn to be unique in existing table - 10-22-2006 , 11:45 AM




mcyi2mr3 (AT) googlemail (DOT) com wrote:
Quote:
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



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.