Puran Mehra
What is difference between UNIQUE and PRIMARY KEY constraints
Posted by Puran Mehra in Database | SQL Server on Aug 04, 2006
0
Do you know the answer for this question? Post it below.
Guest

Unique key- unique key accept only one null value accept.but unique key use many time in table.

Primary key-Primary key does not accept null value and primary key use only one time in table.

Posted by deepak singh on Oct 10, 2011

Unique: unique it allows null value only once.

Primary key: It is unique but it does't allow null value.

Posted by nagabhushan Hiremath on Jul 06, 2011

Below is a nice video which demonstrates the difference between unique and primary key practically.

 

Posted by Shivprasad on Mar 11, 2011

in simple words...
primary key is always unique and not null.
but unique key is only unique it can be null.

Posted by kanchan setia on Feb 03, 2011

From Microsoft SQL server doc: http://msdn.microsoft.com/en-us/library/ms191166.aspx

"UNIQUE constraints allow for the value NULL. However, as with any value participating in a UNIQUE constraint, only one null value is allowed per column."

"Some of the fields can contain null values as long as the combination of values is unique."

So, SQL Server allows only one null in unique contraint.
Oracle allows multiple nulls in a unique contraint column.

Since one null value is never considered equal to another null value oracle processes properly in this case.

Posted by Automata on Oct 12, 2010
Sponsored by
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
Sponsored by
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PRIVACY POLICY | TERMS & CONDITIONS | SITEMAP | CONTACT US | REPORT ABUSE © 2011 C# Corner. All contents are copyright of their authors.