.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Articles >> DataBase >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Difference between Unique key and Primary Key

Posted By:Athira Sreejith       Posted Date: December 31, 2008    Points: 15    Category: DataBase    URL: http://www.dotnetspark.com  

Difference between Unique key and Primary Key..

1. By default primary key will generate clustered index
where as unique key will generate Non-clustered index.

2. Primary key is a combination of unique and NOT NULLConstraint.
So it can't have duplicate value/any NULLs .
Where as unique Key can have any number of Nulls.

3. A table can have only one Primary key.
But it can have number of unique key.

 Subscribe to Articles


Further Readings:

Author: PankajGupta         Company URL: http://www.dotnetspark.com
Posted Date: July 14, 2009

Can you please give me some examples where we can use primary key and where we can use unique keys.

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend