码迷,mamicode.com
首页 > 数据库 > 详细

SQL keys, MUL vs PRI vs UNI

时间:2014-10-27 19:53:10      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:des   http   io   os   ar   for   sp   strong   on   

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


SQL keys, MUL vs PRI vs UNI

DESCRIBE <table>;

This is acutally a shortcut for:

SHOW COLUMNS FROM <table>;

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

  • PRI

  • UNI

  • MUL

The meaning of PRI and UNI are quite clear:

PRI => primary key

UNI=> unique key

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


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


There is also a final caveat:


"If more than one of the Key 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

标签:des   http   io   os   ar   for   sp   strong   on   

原文地址:http://my.oschina.net/xinxingegeya/blog/337843

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!