What is the difference between a primary key and a unique key in a Relational Database Management System (RDBMS)?

1 Answers
Answered by suresh

Difference between Primary Key and Unique Key in RDBMS

Difference between Primary Key and Unique Key in RDBMS

In a Relational Database Management System (RDBMS), a primary key is a column or a set of columns that uniquely identify each row in a table. It ensures that there are no duplicate values in the primary key column and is used to enforce entity integrity.

On the other hand, a unique key is a constraint that ensures that all values in a column or a set of columns are unique, but unlike a primary key, it allows NULL values. A table can have multiple unique keys, but only one primary key.

Both primary key and unique key constraints help in maintaining data integrity and ensuring data accuracy in the database.

Answer for Question: What is the difference between a primary key and a unique key in a Relational Database Management System (RDBMS)?