您的位置:首页 > 数据库 > MySQL

mysql 查看索引

2015-03-25 10:56 716 查看
SHOW INDEX returns table index information. The format resembles that of the SQLStatisticscall in ODBC. This statement requires some privilege for any column in the table.

SHOW INDEX returns the following fields:

• Table The name of the table.

• Non_unique 0 if the index cannot contain duplicates, 1 if it can.

• Key_name The name of the index. If the index is the primary key, the name is always PRIMARY.

• Seq_in_index The column sequence number in the index, starting with 1.

• Column_name The column name.

• Collation How the column is sorted in the index. In MySQL, this can have values “A”(Ascending) or NULL(Not sorted).

• Cardinality An estimate of the number of unique values in the index. This is updated by running ANALYZE TABLE

or myisamchk -a. Cardinalityis counted based on statistics stored as integers, so the value is not

necessarily exact even for small tables. The higher the cardinality, the greater the chance that MySQL

uses the index when doing joins.

• Sub_part The number of indexed characters if the column is only partly indexed, NULLif the entire column is indexed.

• Packed Indicates how the key is packed. NULLif it is not.

• Null Contains YESif the column may contain NULLvalues and ''if not.

• Index_type The index method used (BTREE, FULLTEXT, HASH, RTREE).

• Comment Information about the index not described in its own column, such as disabledif the index is disabled.

• Index_comment Any comment provided for the index with a COMMENTattribute when the index was created

查看索引

mysql> show index from tblname;

mysql> show keys from tblname;

· Table 表的名称。

· Non_unique 如果索引不能包括重复词,则为0。如果可以,则为1。

· Key_name 索引的名称,例如,PRIMARY。

· Seq_in_index
索引中的列序列号,从1开始。

· Column_name 列名称。

· Collation 列以什么方式存储在索引中。在MySQL中,有值‘A’(升序)或NULL(无分类)。

· Cardinality 索引中唯一值的数目的估计值。通过运行ANALYZE TABLE或myisamchk -a可以更新。基数根据被存储为整数的统计数据来计数,所以即使对于
小型表,该值也没有必要是精确的。基数越大,当进行联合时,MySQL使用该索引的机 会就越大。

· Sub_part 如果列只是被部分地编入索引,则为被编入索引的字符的数目。如果整列被编入索引,则为NULL。

· Packed 指示关键字如何被压缩。如果没有被压缩,则为NULL。

· Null 如果列含有NULL,则含有YES。如果没有,则该列含有NO。

· Index_type 用过的索引方法(BTREE, FULLTEXT, HASH, RTREE)。

· Comment
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: