INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

HANDLE


PASSWORD
Remember Me
Forgot Password?

Come Join Us!

  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • Turn Off Ad Banners
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

E-mail*
Handle

Password
Verify P'word
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Member Feedback

"...I have learned more through this forum than I did on a two day course. Thanks to everyone for their help and other postings that I have found useful..."

Geography

Where in the world do Tek-Tips members come from?

MySQL AB: MySQL FAQ

Installation

How can I make an existing column have a unique constraint
Posted: 6 Sep 01

1) Make sure that the column only conains unique values
   lets assume we are working with a table called t5.  it has two columns. id ( the primary key ) and name.  To find out if the  column contains any duplicate values make the following statements.

      select name from t5 ;
      select distinct name from t5 ;


    IF the row counts are the same then the column contains unique values only.

2)  Create a unique index as follows..

        alter table t5 add unique ( name ) ;

        If you want to give the index a name do it this way...

         alter table t5 add unique namedex ( name )

3)  Drink a beer

That's it!

    * You may optionally drink beer between and during steps one and two.

Back to MySQL AB: MySQL FAQ Index
Back to MySQL AB: MySQL Forum
My FAQ Archive
Email This FAQ To A Friend

My Archive