-
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
-
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
-
ALTER TABLE your_table
ADD CONSTRAINT your_unique_constraint UNIQUE (your_unique_column)
-
-
so a primary key consists on a unique key and a not null constraint
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|