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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rasadul Alam RashedPosted Mar 16, 2013, 8:03 AM
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
Sukesh MarlaPosted Aug 14, 2012, 2:52 AM
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
Nattudurai EswaramurthyPosted Aug 14, 2012, 2:50 AM
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