Click here to get back home

setting a collumn to be unique in existing table

 HomeNewsGroups | Search | About
 mailing.database.mysql    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
setting a collumn to be unique in existing table mcyi2mr3@googlemail.com 10-22-2006
Get Chitika Premium
Posted by mcyi2mr3@googlemail.com on October 22, 2006, 12:01 pm
Please log in for more thread options
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


Posted by mcyi2mr3@googlemail.com on October 22, 2006, 12:02 pm
Please log in for more thread options
also the syntax to unset this would also be useful. thanks


Posted by strawberry on October 22, 2006, 12:45 pm
Please log in for more thread options

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


Similar ThreadsPosted
Alter combination of 2 existing columns as a unique key April 19, 2007, 2:07 pm
making a table with unique entries October 11, 2005, 11:44 am
Unique table version record July 26, 2006, 5:52 am
adding contraints FK refs to existing schema April 19, 2006, 11:25 pm
setting database pw November 22, 2005, 3:52 am
setting value for all records November 15, 2006, 8:07 am
C API, setting language, MyISAM August 21, 2005, 10:15 pm
Re-setting mysql as a service September 28, 2005, 8:45 am
setting mySQL parameters via PHPmyadmin November 1, 2006, 8:36 am
MySQL Performance - Option setting February 27, 2007, 2:02 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap