What is the difference between MySQL PRIMARY KEY and UNIQUE constraint?

MySQLMySQLi Database

The following table will provide us the differences between PRIMARY KEY and UNIQUE constraint −

PRIMARY KEY
UNIQUE Constraint
1. Only one Primary key can be created on a table.
1. More than one UNIQUE Constraints can be added to a table.
2. Primary key creates clustered index by default.
2. UNIQUE Constraint creates a non-clustered index by default.
3. We cannot insert null values in the column which is defined as PRIMARY KEY.
3. We can insert null values in the column having a UNIQUE constraint.


raja
Published on 19-Feb-2018 10:33:44
Advertisements