top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

What is the difference between Primary Key and Unique Key?

+2 votes
162 views
What is the difference between Primary Key and Unique Key?
posted May 5, 2014 by Sachin Dahda

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

3 Answers

+2 votes

Both primary key and unique key uniquely identify a record. At higher level we can have is two difference between them.

  1. The not null constraint is by default added to primary key, it means, primary key attribute cannot accept null values, whereas, the attribute declared as unique can accept null values. It is the major difference between the two.
  2. Secondly, we can have only one primary key in a relation, whereas, multiple attributes can be declared unique at the same time.
answer May 6, 2014 by Salil Agrawal
+2 votes

In SQL Server, we have two keys which distinctively or uniquely identify a record in the database. Both the keys seems identical, but actually both are different in features and behaviours.

Primary Key- Primary key can't accept null values.By default, Primary key is clustered index and data in the database table is physically organized in the sequence of clustered index.We can have only one Primary key in a table.

Secondary Key-Unique key can accept only one null value.By default, Unique key is a unique non-clustered index.We can have more than one unique key in a table.

answer May 6, 2014 by Karamjeet Singh
0 votes

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.

answer May 10, 2014 by Vrije Mani Upadhyay
Similar Questions
+1 vote

In my table I have three unique column this can be referred by other table.
Which key I have to use for this.

+1 vote

I am using for MySQL in ubuntu and created more then 7 tables. I haven't used the primary key in the tables.
Now my question is will joiner work without primary keys? If possible please share the query?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...