Differences between Primary key and Unique Key Not Null?
What is the differences between Primary key and Unique Key Not Null?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Nattudurai EswaramurthyRank #5,536 · 296 reputationPosted Aug 13, 2012, 10:50 PM EDT
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.
A UNIQUE constraint is similar to PRIMARY key, but you can have more than one UNIQUE constraint per table.
When you declare a UNIQUE constraint, SQL Server creates a UNIQUE index to speed up the process of searching for duplicates. In this case the index defaults to NONCLUSTERED index, because you can have only one CLUSTERED index per table.
* The number of UNIQUE constraints per table is limited by the number of indexes on the table i.e 249 NONCLUSTERED index and one possible CLUSTERED index.
Contrary to PRIMARY key UNIQUE constraints can accept NULL but just once. If the constraint is defined in a combination of fields, then every field can accept NULL and can have some values on them, as long as the combination values is unique.
Your Response is important to use. Please Check This is Currect Answer, if it helped
Sukesh MarlaRank #461 · 5.4K reputationPosted Aug 13, 2012, 10:52 PM EDT
If you make unique Not Null It can be candidate for primarykey,
some Differences are
By Default Non Clustered Index get Created on UniqueKey regardless of null/not null
Secondly A table can have more than one uniuq keys but only one Primary Keys.
Your Response is important to use. Please Check This is Currect Answer, if it helped
Rasadul Alam Rashed46 reputationPosted Mar 16, 2013, 4:03 AM EDT
A unique key is a column or a set of columns that can uniquely identify a row in a table. So, a unique key is constrained such that no two values of it are equal. Unique key allows only a single NULL value in that column. Depending on the design of a database, a table may have more than one unique key.
Primary Key
A primary key is a column or a set of columns that can uniquely identify a row in a table. A table can have at most one primary key. A primary key have an implicit NOT NULL constraint. So, a column that is defined as the primary key cannot have NULL values in it
for more: http://cybarlab.blogspot.com/2013/01/difference-between-primary-key-and.html