跳到主要内容
版本:2.5

SHOW INDEX

功能

查看索引,当前仅支持查看指定表的所有 Bitmap 索引。创建 bitmap 索引为异步过程,使用该语句只能查看到已经创建完成的索引。

语法

SHOW INDEX[ES] FROM [db_name.]table_name [FROM db_name]

SHOW KEY[S] FROM [db_name.]table_name [FROM db_name]

参数说明

参数必选说明
db_name数据库名称。
table_name表名。

返回结果说明

+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+

返回结果中的参数说明:

参数说明
Key_name索引名称。
Column_name创建索引的列名。
Index_type索引类型。
Comment索引备注。

说明:当前仅支持查看 bitmap 索引,bitmap 索引的相关信息仅包括以上四个参数。返回结果中的其他参数和 bitmap 索引无关。

示例

为表sales_records中的item_id列创建 bitmap 索引,索引名称为index3。表sales_records所属数据库为d0

CREATE INDEX index3 ON sales_records (item_id) USING BITMAP COMMENT '';

查看表sales_records的所有索引。

SHOW INDEX FROM d0.sales_records;

+----------------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+----------------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| default_cluster:d0.sales_records | | index3 | | item_id | | | | | | BITMAP | NULL |
+----------------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+

SHOW KEY FROM sales_records FROM d0;

+----------------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+----------------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| default_cluster:d0.sales_records | | index3 | | item_id | | | | | | BITMAP | NULL |
+----------------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+