# Databases > Oracle Candidate key

## babi_geek

What is a candidate key in oracle?
What is difference between candidate key, primary key and unique key?

----------


## krishnaindia2007

A candidate key uniquely identifies rows in the table.
Any of identified candidate keys can be used as primary key.
Candidate keys that are not part of primary key are called alternate keys.

Primary key will not allow duplicate values and null values.

Foreign key is used to enforce referencial integrity.

----------


## babi_geek

You are saying "any of identified candidate keys can be used as primary key."

Does it mean a candidate key must always satisfy the following two conditions

1. Duplicate values are not allowed
2. Null values are not allowed.


But a table can have only one primary key. If each candidate key is a primary key then it is allowing more than one primary key on a table.

Still I did get clear idea about  candidate key.

Please clarify it.

----------


## krishnaindia2007

In other words Candidate keys are all columns in a table that are not dependent on other columns in the table.

All candidate keys are not primary keys. we choose one of the candidate keys as primary key. A table may contain more than one candidate key but only one primary key column per table is allowed.

I hope now it is clear.

----------


## jmorecroft

I understand what a candidate key is.  Can somebody tell me what the syntax is to create one?

----------


## sunshine60india

Set of fields in database taken collectively to identify any row uniquely is called Candidate key...
So Database has more than 1 Candidate key...

Primary key is the Candidate key choosen by the Database Designer...
 Unique Key is the constraint that is used to insert unique value in the field of the database...


Thanks ,, Vipul Patel

----------

