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 |
hey friends, What are the steps I can do to transfer the database from Microsoft Access 2003 to oracle10g (or SQL) Best regards
What is a nested table?
What is the difference between the Oracle ODBC driver and a Microsoft ODBC (Open Database Connectivity) Driver?
what is the difference between rollback & commit? can a foreign key has null value?
what is the scenario where you take the database to NoArchivelog mode?
1. Display all the rows and columns in the CLIENT table. Sort by client name in reverse alphabetical order.
What is primefaces used for?
What are steps required to ENTER DATA INTO DWH?
Her departmandaki isçilerden empno' su ikinci sirada olan isçilerin empno, deptno, hiredate, sira_no bigilerini döndüren sorguyu yaziniz?
is there a tool to trace queries, like profiler for sql server?
The table has 3 columns 4 rows. The output is which column has least null values( A COL SHOULD BE THE OUTPUT) Write the query plz. A B C ================ 1 NULL 2 NULL 3 4 NULL 5 6 7 NULL NULL O/P C = 2 4 6
Can group functions be used in the order by clause in oracle?