KnowledgeBoat Logo

Computer Science

What is the role of UNIQUE constraint ? How is PRIMARY KEY constraint different from UNIQUE constraint ?

DDL & DML

2 Likes

Answer

UNIQUE constraint ensures that no two rows have the same value in the specified column(s).
There are differences between UNIQUE and PRIMARY KEY constraints. Though both ensure unique values for each row in a column, but UNIQUE allows NULL values whereas PRIMARY KEY does not. Also, there can exist multiple columns with UNIQUE constraints in a table, but there can exist only one column or one combination with PRIMARY KEY constraint.

Answered By

1 Like


Related Questions