h1

Making a field unique after creating a table

December 15, 2010

The MySQL browser on Linux doesn’t appear to let you add unique column indexes to a table in retrospect after the table has been created. There are mysql commands though which allow this:

ALTER TABLE tablename ADD UNIQUE name_of_index (col1,col2...);

Statement to make unique columns without altering table:

CREATE UNIQUE INDEX name_of_index ON tablename (col1,col2,col3...);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: