Difference Between Primary Key and Unique Key
Primary Key |
Unique Key |
---|---|
A primary key cannot have a NULL value. |
Unique keys can have one NULL value. |
The table can have only one primary key. |
The table can have more than one unique key. |
Any change in primary key value may necessitate updates in related tables to maintain referential integrity. |
A unique key can be updated or deleted, it doesn’t affect the table’s integrity constraints. |
In some databases, the primary key can generate a clustered index by default. |
In some databases, a unique key can generate a non-clustered index by default. |
Unique Key in DBMS
A column or set of columns in a database system that uniquely identifies each tuple in the table is called a unique key. A unique key ensures that no two rows in the table have the same combination of values, so it enforces data integrity by preventing duplicity of the values in the table. In this article, we are going to see about the unique keys in DBMS along with their implementation in the table. Let’s start with the definition of a unique key.
Contact Us