New Member FAQ
|
Forums
|
Earn Revenue
|
Distance Education
|
Help Topics
|
Admissions 2013
Login
Register
Articles
Practice Tests
Ask Experts
Question Papers
Jobs
Universities
Colleges
Courses
Schools
Gift Shop
|
Bookmarks
|
Reviews
|
Learn English
|
Social Hub
|
Training
|
New Posts
|
My India
|
Members
|
Polls
|
Active Members
Today
R Pramod
(133)
MANIKANDAN
(117)
mahi patel
(110)
Last 7 Days
R Pramod
(1039)
K Mohan
(716)
Pritan Tiwari
(541)
more...
Resources
»
Articles/Knowledge Sharing
»
Computer & Technology
Difference between Primary Key and Unique Key
Posted Date:
20-Dec-2009
Category:
Computer & Technology
Author:
Arvind Kumar Chauhan
Member Level:
Silver
Points
: 10
Hi Friends,
Difference between Primary Key and Unique Key is a very key question and it is generally asked in interview and in exams as well. I have listed the difference between Primary Key and Unique key below:-
Primary Key
1)
Can not contain NULL values, this is because when we create a primary key, the NOT NULL constraint is automatically created for the column(s) the primary key is set. Note:- Unique key constraint is also created automatically therefore Primary Key is a combination of Unique Key constraint and NOT NULL constraint.
2)
We can have only one Primary Key per table.
3)
Creates clustered index by Default. We can have only one clustered index.
4)
Primary key is used to uniquely identify a row or record in a table. Primary key ensures that no duplicate rows exist in a table.
Unique Key
1)
Can or can’t contain NULL values i.e. if we define unique key on a column which is not null , then this unique key can also be used as an alternate primary key functionality to identify unique rows in a table. Note: - The number of NULL values a column can contain depends on RDBMS we are using i.e. SQL Server and DB2 don’t allow more than one NULL values whereas in Oracle we can have more than one NULL value.
2)
We can have more than one Unique Key per table
3)
Creates non-clustered index by Default
4)
Unique key constraint ensures that no two rows contain duplicate value in a column or field, but if it is used with NOT NULL column then this can also serve the purpose of Primary key or can be used as alternate primary key.
Hope this will help you in understanding the concept of Primary Key and Unique Key. If you still have some doubt or needs more information you are always welcome.
With Regards,
Arvind
Did you like this resource? Share it with your friends and show your love!
Tweet
Responses to "Difference between Primary Key and Unique Key"
No responses found. Be the first to respond...
Feedbacks
Post Comment:
Notify me by email when others post comments to this article.
Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
No HTML formatting and links to other web sites are allowed.
This is a strictly moderated site. Absolutely no spam allowed.
Name:
Sign In
to fill automatically.
Email:
(Will not be published, but
required
to validate comment)
Type the numbers and letters shown on the left.
Next Resource:
DLR-Dynamic Language Runtime
Previous Resource:
Internet protocol
Return to Resources
Post New Resource
Category:
Computer & Technology
Post resources and
earn money
!
More Resources
DLR-Dynamic Language Runtime
OLE Fundamentals
Accessing Data Source using the Remote Data Control.
Data Report
File Server Architecture
Multiple Document Interface
Popular Tags
Tag posting guidelines
Search Tags
Difference between Primary Key and Unique Key
.
Primary Key Vs Unique Key
.
Subscribe to Email
Get Jobs by Email
Forum posts by Email
Articles by Email
Awards & Gifts
Online Members
K Mohan
jenti j b deka
More...