Difference between primary key and unique key ?
Answers were Sorted based on User's Feedback
Answer / dpkar
Primary Key:
Primary key will create column data uniqueness in the table.
Primary key will create clustered index by default
Only one Primay key can be created for a table
Multiple columns can be consolidated to form a single
primary key
It wont allow null values.
Unique Key :
Unique key constraint will provide you a constraint like
the column values should retain uniqueness.
It will allow null value in the column.
It will create non-clustered index by default
Any number of unique constraints can be added to a table.
| Is This Answer Correct ? | 2 Yes | 4 No |
Answer / priyranjan das
The basic differences between Primary Key and Unique key are as follows.
1) By default Primary Key will generate Clustured Index
whereas Unique Key will Generate Non-Clustured Index.
2) Primary Key is a combination of Unique and NOT NULL Constraints so it can’t
have duplicate values or any NUll
Whereas for Oracle UNIQUE Key can have any number of NULL whereas for SQL
Server It can have only one NULL
3) A table can have only one PK but It can have any number of UNIQUE Key.
| Is This Answer Correct ? | 2 Yes | 4 No |
Answer / kundn
Unique key Primary key
1. Can have null value 1. Can not have null value
2.Table can have multiple 2. Table Can have multiple unique
Unique keys keys
3Single column at a time 3. May be combination of one or
or more columns
| Is This Answer Correct ? | 14 Yes | 17 No |
Answer / ajoy
primary key and unique key both can be referenced to other
table as foreign key. please check this error message
ORA-02270: no matching unique or primary key for this
column-list
| Is This Answer Correct ? | 4 Yes | 7 No |
Answer / guna
there is only one primary key for one table;
it can not acept null values;
any no uniquefor a table;
it can accept null values;
which the rows are unique value;
| Is This Answer Correct ? | 9 Yes | 18 No |
Answer / vitthal parkar
Unique key Primary key
1. Can have null value 1. Can not have null value
2.Table can have multiple 2. Table Can have multiple unique
Unique keys keys
3Single column at a time 3. May be combination of one or
or more columns
| Is This Answer Correct ? | 35 Yes | 58 No |
Is oracle a relational database?
Write a syntax for update query in oracle?
pls explain connect by prior with example and its real time use
Display those managers salary greater than the average salary of his employees?(Based on oracle standard Emp table)
What is a table index in oracle?
which sql command we can use to get a print out from oracle?
What is oracle host variable?
Is there an oracle sql query that aggregates multiple rows into one row?
What is a Garbage Collection? and what is full recursive Garbage collection?
How to join two tables in a single query using oracle?
> CREATE OR REPLACE FUNCTION FACTORIAL_1(factstr varchar2 ) 2 RETURN NUMBER AS 3 new_str VARCHAR2(4000) := factstr||'*' ; 4 fact number := 1 ; 5 BEGIN 6 7 WHILE new_str IS NOT NULL 8 LOOP 9 fact := fact * TO_NUMBER(SUBSTR(new_str,1,INSTR(new_str,'*')-1)); 10 new_str := substr( new_str,INSTR(new_str,'*')+1); 11 END LOOP; 12 13 RETURN fact; 14 15 END; explanation Above program?
What is an oracle cursor variable?