SQL keys, MUL vs PRI vs UNI

Source: Internet
Author: User
Tags mul

Excerpt from: http://stackoverflow.com/questions/5317889/sql-keys-mul-vs-pri-vs-uni/15268888#15268888


SQL keys, MUL vs PRI vs UNI

DESCRIBE <table>;

Acutally a shortcut for:

SHOW COLUMNS from <table>;

In any case, there is three possible values for the "Key" attribute:

    • Pri

    • UNI

    • MUL

The meaning of the PRI and UNI are quite clear:

PRI = Primary Key

Uni=> Unique Key

The third possibility, MUL, (which you asked on) is basically an index, which is neither a primary key nor a unique key. The name comes from "multiple" because multiple occurences of the same value is allowed. Straight from the MySQL documentation:http://dev.mysql.com/doc/refman/5.1/en/show-columns.html


"If Key is MUL, the column was the first column of a nonunique index in which multiple occurrences of a given value was per Mitted within the column. "


There is also a final caveat:


"If more than one of the keys values applies to a given column of a table, Key displays the one with the highest priority, In the order PRI, UNI, MUL. "


As a general note, the MySQL documentation is quite good. When in doubt, check it out!

====end====

SQL keys, MUL vs PRI vs UNI

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.