A field that defines a unique constraint cannot contain duplicate values, and you can define a unique constraint for one or more fields, so unique can be defined at the field level or at the table level.
You can include null values on fields that are uniqued constrained. Note that you can include null values
Oracle automatically establishes a unique index and a NOT NULL constraint for a field with a PRIMARY KEY constraint (the primary Code field), which can be indexed when the primary KEY constraint is defined
Uniqued nullable, one or more fields that can be defined in one table
PRIMARY key is not empty and cannot be duplicated, in a table you can define a joint primary key
Simply put, the primary key = unique + NOT NULL
Unique is unique when you need to qualify one of your table fields for each value that is unique and has no duplicate values.
For example, if you have a person table and you have an ID column in the table, you can specify that the field is unique.
When you define a foreign key, the field referenced can only be a field that has (primary key or unique), and the primary key differs from the index of the unique field
Unique can contain null values, and a table can have multiple unique constraint
And PrimaryKey can only have one in a table. and cannot have null values.
From a technical point of view, there are many similarities between the Primary key and the unique key. But there are still the following differences:
A domain/domain group that is a primary key cannot be null. And the unique key can.
There can be only one primary key in a table, and multiple unique keys can exist at the same time.
The larger difference is in the logical design. Primary key is typically used as a record identifier in the logical design, which is also the setting
The original intention of Primary key. The unique key is only to guarantee the uniqueness of the domain/domain group.