syntax for making the column as unique
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: syntax for making the column as unique

  1. #1
    Join Date
    Feb 2000
    Location
    New York,U.S.A.
    Posts
    245
    Hi,
    I need help in finding out the syntax for adding unique constrant on the column. I have one column called username, which is NOT NULL already, but I also want this column to be unique(no duplicate). I could not find syntax which is working. Thanks for help.

    Dragon

  2. #2
    Join Date
    Oct 2000
    Location
    Dallas:TX:USA
    Posts
    407
    you can either create a Primary Key constraint on this column (which will create a unique index as well) or just create a unique index on this column.

    - Rajeev
    Rajeev Suri

  3. #3
    Join Date
    Jul 2000
    Posts
    296
    ALTER TABLE your_table
    ADD CONSTRAINT your_unique_constraint UNIQUE (your_unique_column)

  4. #4
    Join Date
    Feb 2000
    Location
    New York,U.S.A.
    Posts
    245
    Thanks.

  5. #5
    Join Date
    Mar 2001
    Posts
    188
    so a primary key consists on a unique key and a not null constraint
    Best Regards
    Thomas Schmidt

    Thomas_Schmidt@eplus-online.de
    If you have no aims, you will never reach a goal !!!

  6. #6
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Originally posted by tomate
    so a primary key consists on a unique key and a not null constraint
    It used to be like this, but not any more. Now you can have a primary key constraint built on a non-unique index. But of course, the indexed values still need to be unique in order the PK constraint to be enforced.
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width