Both keys ensure that a column or a combination of columns in a table or relation is unique. The primary key identifies each record in the table, whereas the unique key, with the exception of NULL values, prevents duplicate entries in a field.
The UNIQUE constraint assures that each column's values are unique. The UNIQUE and PRIMARY KEY constraints both guarantee that a column or collection of columns is unique. A UNIQUE constraint is immediately added to a PRIMARY KEY constraint.
A group of one or more table fields/columns that uniquely identify a record in a database table is known as a unique key. It's similar to a primary key in that it can only accept one null value and cannot have duplicate values.
A group of one or more fields/columns in a table that uniquely identify a record in a database table is known as a unique key. It's similar to a primary key in that it accepts just one null value and cannot have duplicate values.