Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2023-08-24 17:57:07
forward
1110 people have browsed it

MySQL PRIMARY KEY 和 UNIQUE 约束有什么区别?

The following table will provide us the difference between PRIMARY KEY and UNIQUE constraints-

tr>
Primary Key

Unique constraint

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!