About the primary key primul in MySQL

Source: Internet
Author: User
Although the combination of multiple indexed columns is unique, for example, ID + NAME is unique, no single column can still have duplicate values, as long as ID + NAME is unique.

Although the combination of multiple indexed columns is unique, for example, ID + NAME is unique, no single column can still have duplicate values, as long as ID + NAME is unique.

1. If the Key is null, the column value can be repeated, indicating that the column has no index or a non-leading column with a non-unique composite index.

2. If the Key is PRI, this column is an integral part of the primary Key.

3. If the Key is UNI, this column is the first column (Leading column) of a unique value index, and does not contain NULL values)

4. if the Key is MUL, the values of this column can be repeated. This column is a non-unique index leading column (the first column) or a unique index component, but it can contain NULL values.

If the definition of a column meets multiple of the above four conditions, for example, a column is both PRI and UNI

When "desc table name" is used, the displayed Key value displays PRI-> UNI-> MUL based on the priority.

Then, PRI is displayed.

A unique index column can be displayed as PRI, and the column cannot contain null values. At the same time, the table does not have a primary key.

A unique index column can be displayed as MUL. If multiple columns constitute a unique compound index

Although the multi-column combination of indexes is unique, for example, ID + NAME is unique, no single column can still have duplicate values.

As long as ID + NAME is unique

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.