Unique index
A unique index does not allow two rows to have the same index value.
If duplicate key values exist in the existing data, most databases do not allow the newly created unique index to be saved with the table.
The database also rejects this data when the new data duplicates the key values in the table. For example, if a unique index is created on the employee's last name (lname) column in the Employee table, all employees cannot have the same surname.
Primary key Index
A primary key index is a special type of unique index.
A database table typically has a column or combination of columns whose values are used to uniquely identify each row in the table. This column is called the primary key of the table.
Defining a primary key for a table in a database diagram automatically creates a primary key index. The primary key index requires that each value in the primary key be unique. When a primary key index is used in a query, it also allows for fast access to the data.
Some of their comparisons:
(1) for the main jian/unique constraint, Oracle/sql server/mysql and so on will automatically establish a unique index;
(2) The primary key does not necessarily contain only one field, so if you Jianjian a unique index in one of the primary keys, it is necessary;???
(3) Primary key can be used as external health, the unique index is not;
(4) The primary key cannot be empty, the unique index can be;
(5) The primary key is also a combination of multiple fields;
(6) There can be only one primary key per table.
Unique index && PRIMARY key index