Home » Interview Q&A » Difference between a primary key and a unique key

Difference between a primary key and a unique key

Cross page posting asp.net
How to write SQL Query to get desire output-3

Both primary key and unique enforce uniqueness of the column on which they are defined. But, there are some differences as well which are as below:

Primary Key Unique Key
 Creates a clustered index on the column  Creates a nonclustered index
 Doesn’t allow NULL  Allows one NULL only,but the unique key is defined 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.
Only one Primary key can be created for a table.
Multiple columns can be consolidated to form a single primary key.
Any number of unique constraints can be added to a table

About

Hello friends, My self Dhruv Sheth, I have more than 6 years of Industrial experience as a Software Developer. In my career I got chance to work with asp.net, c#,Web API, JavaScript, JQuery, WPF, WCF , Windows Application, PostScript, vb.net, GhostScript etc. So I have decided to share my knowledge with everyone and finally I have come up with TechnoThirsty.

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

Time limit is exhausted. Please reload CAPTCHA.




DISCLAIMER:
The content is copyrighted to technothirsty.com and may not be reproduced on other websites without permission from the owner.You may contact us using the information below.