GBase8a 集群查看表索引

GBase 8a数据库集群,当前版本目前只支持一种hash索引,同时提供了元数据表 information_schema. statistics 查看索引情况。

gbase> select * from information_schema.statistics where table_schema='testdb'; 其中GLOBAL HASH是hash索引,GROUPED是行存列索引,其为一个数据结构,内部使用,不算标准索引类型。

样例

gbase> show create table t1;
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                      |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE "t1" (
  "id" int(11) DEFAULT NULL,
  "value" int(11) DEFAULT NULL
) ENGINE=EXPRESS DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> create index idx_id on testdb.t1(id) key_block_size=4096 using hash global;
Query OK, 0 rows affected (Elapsed: 00:00:01.62)
Records: 0  Duplicates: 0  Warnings: 0

gbase> show create table t1;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                                   |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE "t1" (
  "id" int(11) DEFAULT NULL,
  "value" int(11) DEFAULT NULL,
  KEY "idx_id" ("id") KEY_BLOCK_SIZE=4096 USING HASH GLOBAL
) ENGINE=EXPRESS DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select * from information_schema.statistics where table_schema='testdb';
+---------------+--------------+------------+------------+--------------+------------+--------------+-------------+-----------+-------------+----------+--------+----------+-------------+---------+
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | NON_UNIQUE | INDEX_SCHEMA | INDEX_NAME | SEQ_IN_INDEX | COLUMN_NAME | COLLATION | CARDINALITY | SUB_PART | PACKED | NULLABLE | INDEX_TYPE  | COMMENT |
+---------------+--------------+------------+------------+--------------+------------+--------------+-------------+-----------+-------------+----------+--------+----------+-------------+---------+
| NULL          | testdb       | t1         |          1 | testdb       | idx_id     |            1 | id          | NULL      |        NULL |     NULL | NULL   | YES      | GLOBAL HASH |         |
+---------------+--------------+------------+------------+--------------+------------+--------------+-------------+-----------+-------------+----------+--------+----------+-------------+---------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select * from information_schema.statistics where table_schema='testdb'\G;
*************************** 1. row ***************************
TABLE_CATALOG: NULL
 TABLE_SCHEMA: testdb
   TABLE_NAME: t1
   NON_UNIQUE: 1
 INDEX_SCHEMA: testdb
   INDEX_NAME: idx_id
 SEQ_IN_INDEX: 1
  COLUMN_NAME: id
    COLLATION: NULL
  CARDINALITY: NULL
     SUB_PART: NULL
       PACKED: NULL
     NULLABLE: YES
   INDEX_TYPE: GLOBAL HASH
      COMMENT:
1 row in set (Elapsed: 00:00:00.00)

ERROR:
No query specified

其它元数据信息请参考

http://www.gbase8.cn/?tag=%e5%85%83%e6%95%b0%e6%8d%ae