Difference between a primary key and a unique key in SQL?

Difference between a primary key and a unique key in SQL?

Tags..  SQL Server  DBA  Asp.Net Interview  Database
Views: 285 | Community Opinion/Answer: 3

Add Your Opinion

Bookmark this page..



Ask a New Question Go to Home


Community Opinion/Answers
Sam Smith said..

In SQL both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a non-clustered index by default. Another major difference is that, primary key doesn't allow NULLs, but unique key allows one NULL only.

Lakshmi said..

There can be more than one unique values for the columns in a table.

There is only one primary key for a column and primary key can be associated with other tables with foreign key relationship.

This is not possible with Unique key

Lakshmi said..

There is a correction

There is only one primary key for a table.


What do you think? Add your opinion/answer
Your Name:
*your opinion/answer: