In this SQL Tutorial, We will explore about the Difference Between Primary key and Unique Key in Oracle SQL.
What is the Primary key in Oracle?
The Primary key is a constraint which defines the rule to the table column. A primary key is unrepeatable, identifies record or unrepeatable rows in the table.
The Primary key can never contain a null value because it has an implicit Not Null constraint. It always contains a unique value.
What is a Unique Key in Oracle?
The Unique Key is also a constraint which defines the rule to the table column. That means if you define any column as a Unique Key then you cannot insert duplicate values and all values of the column will be different.
You can use Unique Key constraints on the multiple columns of the table.
Primary Key vs Unique Key in Oracle
Primary Key |
Unique Key
|
A Table can have only one Primary Key.
|
A Table can have more than one Unique Key.
|
A Primary Key cannot store null values.
|
A Unique Key Column can store one NULL Values.
|
Uniquely Identify each row in a table.
|
Uniquely Identify each value in a column.
|
Foreign Key can refer to Primary Key.
|
Foreign Key cannot refer to Unique Key.
|
That's all for today, I think (Difference Between the Primary Key and Unique Key in the Oracle) post will be helpful for you.
If you like this post then share your valuable comment in the comment section.
0 Comments
If you have any doubts, Please let me know