C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Difference between Unique key and Primary Key


Posted Date: 29 Sep 2008    Resource Type: Articles    Category: Databases

Posted By: Athira Appukuttan       Member Level: Diamond
Rating:     Points: 2



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.




Responses

Author: Narayanan Sukumaran    29 Sep 2008Member Level: Gold   Points : 1
Hi Athira Appukuttan ,

Do you have any INDEX related articles?
What is clustered index and Non-clustered index? Difference?
How to crete clustered index and Non-clustered index?



Author: Bunty    02 Oct 2008Member Level: Diamond   Points : 1
Hi,

Athira,

We can have at the max one null value in unique constraint not many.
so just check that.

Regards
S.S.Bajoria


Author: anil    03 Oct 2008Member Level: Silver   Points : 1
Hi
Aathira,

What is de diff b/w clustered index and Non-clustered index?

thanks,
Anil...


Author: Sriram    05 Oct 2008Member Level: Gold   Points : 2
Hi,

Primary Key : Primary Key Restrict Duplicate Values and null Values .Each Table Can have only one primary Key.

Unique Key: Unique Key Restrict Duplicate Values and allow only one Null Values.

Primary Key Default is Clustered Index its Sequential Order.
Unique Key Default is Non Clustered Index

Thanks and Regards
SriramRamaswamy


Author: Roopesh Babu Valluru    14 Oct 2008Member Level: Gold   Points : 1
yes man...only one null is allowed for unique key column...pls try to correct it...




Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Difference between Unique key and Primary Key  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Cursors in SQL:
Previous Resource: Indexes in SQL
Return to Discussion Resource Index
Post New Resource
Category: Databases


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

it support

Contact Us    Privacy Policy    Terms Of Use