Fields defining the UNIQUE constraint cannot contain duplicate values. You can define a UNIQUE constraint for one or more fields. Therefore, UNIQUE can be defined at the field or table level, fields with UNIQUE constraints can contain null values. ORACLE automatically creates a unique index and a not null constraint for fields with the primary key constraint (PRIMARY code segment). When defining the primary key constraint, it can be its index; UNIQUED can be empty, one or more fields in a table can be defined;
Primary key cannot be empty and cannot be repeated. You can define a joint primary key in a table. In short, primary key = unique + not null
Unique is unique. It is used when you need to limit that each value of a table field is unique and there are no duplicate values. for example, if you have a person_Info table with a column ID card, you can specify this field unique.
From a technical point of view, there are many similarities between Primary Key and Unique Key. However, there are the following similarities and differences:
Same: they all belong to entity integrity constraints.
Differences:
(1) The column where the uniqueness constraint is located allows null values, but the column where the primary key constraint is located does not allow null values.
(2) You can place the uniqueness constraint on one or more columns. The combination of these columns or columns must be unique. However, the column where the uniqueness constraint is located is not the primary key column of the table.
(3) The uniqueness constraint forces the creation of a unique index on the specified column. By default, a unique non-clustered index is created. However, you can also specify that the created index is a clustered index.
(4) The primary key is created so that the foreign key can be referenced.
(5) A table can have at most one primary key, but it can have many unique keys.