Home >Database >Mysql Tutorial >What is the difference between MySQL PRIMARY KEY and UNIQUE constraints?
The following table will provide us the difference between PRIMARY KEY and UNIQUE constraints-
Primary Key | Unique constraint | tr>
---|---|
1. A table can only create one primary key. | 1. Multiple UNIQUE constraints can be added to a table. |
#2. The primary key creates a clustered index by default. | 2. UNIQUE constraints create non-clustered indexes by default. |
#3. We cannot insert null values in columns defined as PRIMARY KEY. | 3. We can insert null values in columns with UNIQUE constraints. |
The above is the detailed content of What is the difference between MySQL PRIMARY KEY and UNIQUE constraints?. For more information, please follow other related articles on the PHP Chinese website!