Difference between primary key and unique key ?
Answers were Sorted based on User's Feedback
Answer / vaithianathan
primary key not accepts null value and
not allows duplicate values.
but Unique key not allows duplicate values
but it accepts ONLY ONE NULL VALUE.
only one primary key allowed per table
we can create multiple unique keys
on the table
By Default, Primary key creates Clustered Index and Unique key Creates Non Clustered Index
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / vijay
Primary key's main role is to make field as unique and
relates to other sub table. Whereas unique is role only to
keep unique value in that field.
Is This Answer Correct ? | 4 Yes | 2 No |
Answer / sripathi venkata ramesh
I am Sripathi Venkata Ramesh from Gudivada and the answer
is mentioned below
Primary key: A Primary key is a column or group of columns
used to uniquely identify each row in a table like
It defines the column as a Mandatory column.
The data held across the column must be unique.
By default it creates clustered index.
It does not allow null values and duplicate values
Unique key: It also for the record uniqueness.
It allows only one null value
By default it creates non clustered index
Is This Answer Correct ? | 3 Yes | 1 No |
Answer / avesh upadhyay,iims
are yar
primary key that does not accept null value
and in table only one exist.
but the case of uniue key that accept null value one or more
and many unique key exist in a single table
Is This Answer Correct ? | 4 Yes | 2 No |
Answer / boomiraj.p
Primary key: Do not allow the
duplicates and null values.
Unique key : Do not accept the
duplicates,but allow null value
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / saga
--->We Define only one PK per table but it should have one
or more UK.
--->PK does not contain null but UK contains null.
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / laxman k
1) Primary key can not accept null values, but unique can
accept null values.
2) only one primary key have in a table but max 249 unique
in a table
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / bhushan tatar
column having primary key constraint should not contain
null values.
column having unique key constraint can contain null values.
Unique as well as primary key constraint can be
defined/applyed on more than one column.
EX.
ADD constraint uc_person UNIQUE(P_Id,Lastname)
ADD constraint uc_person PRIMARY KEY(P_Id,Lastname)
But whle creating table we can write unique key word
multiple time and primary key wprd only once.Because table
can have only one primary key and can have miltiple unique
key.But both can apply on more than one column.
and
Is This Answer Correct ? | 10 Yes | 9 No |
Answer / sandhya
Primary Key cannot contain null values
Each table has one and only one Primary Key
Primary Key is used to reference as Foreign key while
performing table joins
Clustered index is created on Primary Key
Unique Key can contain null value
A table can have any numberof unique keys
Non-clustered index is created on unique key columns
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / deen dayal sharma
1. PRIMARY KEY & UNIQUE KEY both uniquely identity of each
row in a table.
2. BOTH keys will not contain repeated value.
3. One table may have more than one Unique Key Constraint But
it should have only one Primary Key Constraint column.
4. BUT UNIQUE KEY will contain NULL value but PRIMAY key will
not contain NULL value.
Is This Answer Correct ? | 1 Yes | 0 No |
What operating systems are supported by oracle database 10g xe?
What are the Characteristics of Data Files ?
how to we delete a row using varray
various types of joins
Difference between inner join vs where ?
What is hash cluster in oracle?
What is the difference between online and offline backups?
Explain oracle instance.
Differentiate between function and procedure in oracle.
What is a deadlock ? Explain .
How to enter a new row into a table interactively?
After using set unused can we enable the column again to use? Please give me some answers....