A UNIQUE constraint is similar to PRIMARY key, but you can have more than one UNIQUE constraint per table.
When you declare a UNIQUE constraint, SQL Server creates a UNIQUE index to speed up the process of searching for duplicates. In this case the index defaults to NONCLUSTERED index, because you can have only one CLUSTERED index per table.
* The number of UNIQUE constraints per table is limited by the number of indexes on the table i.e 249 NONCLUSTERED index and one possible CLUSTERED index.
Contrary to PRIMARY key UNIQUE constraints can accept NULL but just once. If the constraint is defined in a combination of fields, then every field can accept NULL and can have some values on them, as long as the combination values is unique.
The basic differences between Primary Key and Unique key are as follows.
1) By default Primary Key will generate Clustured Index
whereas Unique Key will Generate Non-Clustured Index.
2) Primary Key is a combination of Unique and NOT NULL Constraints so it can’t
have duplicate values or any NUll
Whereas for Oracle UNIQUE Key can have any number of NULL whereas for SQL
Server It can have only one NULL
3) A table can have only one PK but It can have any number of UNIQUE Key.
It is good try to collect more points
Hi,
Good explanation
Very clear and helpful explanation! Thanks a lot
good
If possible,pls include a detailed explanation…
Primary Key does not allow null values where as unique constraint allow ’single’ null value.
A table can have only single Primary Key where as it can have multiple unique constraints ( max 16)
Very good. Many thanks
Very good explanation difference between primary key and unique key
its very good article..
thks a lot
thks a lot to Rubinaalexmary
regards
achiever.
Simly Great….
excellent, thanks a lot….
ty so much
Nice arctical ……
its good, but pls try to give the detailed description about the differences
Good explanation..
txs
nirmala
good explanation
Are govind chuudaraa
jaheer gaadiki kuuda cheppu
Rubinaalexmary thank you very much for your precision made on March 1, 2007
Helped a lot..
nice, useful for getting knowledge from the scratch.
Please give an example.
thanks, very good explanation
Very Well Explanation.
Thanks for your help
Very nice explanation
Its very good and very clear explanation. Thank you so much