mysql>SHOW INDEX FROM table_name; +------------+------------+-------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | Table , Non_unique, Key_name , Seq_in_index, Column_name, Collation, Cardinality, Sub_part, Packed, Null, Index_type, Comment, Index_comment, +------------+------------+-------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | table_name, 0, PRIMARY , 1, id , A , 1000000, NULL, NULL , , BTREE , , , | table_name, 0, unique_index_name , 1, unique_col1, A , 1000000, NULL, NULL , , BTREE , , , | table_name, 0, unique_index_name , 2, unique_col2, A , 1000000, NULL, NULL , , BTREE , , , +------------+------------+-------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
在MySQL中,系统表information_schema中的STATISTICS表记录了所有表的索引信息。通过SHOW INDEX命令可以查询到表的索引信息,其中Index_name字段即代表索引的名称。如果有多个Unique索引,那么他们的名字是不同的,各自存储在系统表中。
综上所述,MySQL中的Unique索引是存储在系统表information_schema.STATISTICS表中的,可以通过SHOW INDEX FROM命令查询得到。