• Information Schema
    • ANALYZE_STATUS Table
    • CHARACTER_SETS Table
    • COLLATIONS Table
    • COLLATION_CHARACTER_SET_APPLICABILITY Table
    • COLUMNS Table
    • ENGINES Table
    • KEY_COLUMN_USAGE Table
    • PROCESSLIST Table
    • SCHEMATA Table
    • SESSION_VARIABLES Table
    • SLOW_QUERY Table
    • STATISTICS Table
    • TABLES Table
    • TABLE_CONSTRAINTS Table
    • TIDB_HOT_REGIONS Table
    • TIDB_INDEXES Table
    • TIKV_REGION_PEERS Table
    • TIKV_REGION_STATUS Table
    • TIKV_STORE_STATUS Table
    • USER_PRIVILEGES Table
    • VIEWS Table
    • 不支持的 Information Schema 表

    Information Schema

    为了和 MySQL 保持兼容,TiDB 支持很多 INFORMATION_SCHEMA 表,其中有不少表都支持相应的 SHOW 命令。查询 INFORMATION_SCHEMA 表也为表的连接操作提供了可能。

    ANALYZE_STATUS Table

    ANALYZE_STATUS 表提供正在执行的收集统计信息的任务以及有限条历史任务记录。

    1. mysql> select * from `ANALYZE_STATUS`
    2. +--------------+------------+----------------+-------------------+----------------+---------------------+----------+
    3. | TABLE_SCHEMA | TABLE_NAME | PARTITION_NAME | JOB_INFO | PROCESSED_ROWS | START_TIME | STATE |
    4. +--------------+------------+----------------+-------------------+----------------+---------------------+----------+
    5. | test | t | | analyze index idx | 2 | 2019-06-21 19:51:14 | finished |
    6. | test | t | | analyze columns | 2 | 2019-06-21 19:51:14 | finished |
    7. | test | t1 | p0 | analyze columns | 0 | 2019-06-21 19:51:15 | finished |
    8. | test | t1 | p3 | analyze columns | 0 | 2019-06-21 19:51:15 | finished |
    9. | test | t1 | p1 | analyze columns | 0 | 2019-06-21 19:51:15 | finished |
    10. | test | t1 | p2 | analyze columns | 1 | 2019-06-21 19:51:15 | finished |
    11. +--------------+------------+----------------+-------------------+----------------+---------------------+----------+
    12. 6 rows in set

    CHARACTER_SETS Table

    CHARACTER_SETS 表提供字符集相关的信息。TiDB 目前仅支持部分字符集。

    1. mysql> SELECT * FROM character_sets;
    2. +--------------------+----------------------+---------------+--------+
    3. | CHARACTER_SET_NAME | DEFAULT_COLLATE_NAME | DESCRIPTION | MAXLEN |
    4. +--------------------+----------------------+---------------+--------+
    5. | utf8 | utf8_bin | UTF-8 Unicode | 3 |
    6. | utf8mb4 | utf8mb4_bin | UTF-8 Unicode | 4 |
    7. | ascii | ascii_bin | US ASCII | 1 |
    8. | latin1 | latin1_bin | Latin1 | 1 |
    9. | binary | binary | binary | 1 |
    10. +--------------------+----------------------+---------------+--------+
    11. 5 rows in set (0.00 sec)

    COLLATIONS Table

    COLLATIONS 表提供了 CHARACTER_SETS 表中字符集对应的排序规则列表。TiDB 当前仅支持二进制排序规则,包含该表仅为兼容 MySQL。

    1. mysql> SELECT * FROM collations WHERE character_set_name='utf8mb4';
    2. +------------------------+--------------------+------+------------+-------------+---------+
    3. | COLLATION_NAME | CHARACTER_SET_NAME | ID | IS_DEFAULT | IS_COMPILED | SORTLEN |
    4. +------------------------+--------------------+------+------------+-------------+---------+
    5. | utf8mb4_general_ci | utf8mb4 | 45 | Yes | Yes | 1 |
    6. | utf8mb4_bin | utf8mb4 | 46 | | Yes | 1 |
    7. | utf8mb4_unicode_ci | utf8mb4 | 224 | | Yes | 1 |
    8. | utf8mb4_icelandic_ci | utf8mb4 | 225 | | Yes | 1 |
    9. | utf8mb4_latvian_ci | utf8mb4 | 226 | | Yes | 1 |
    10. | utf8mb4_romanian_ci | utf8mb4 | 227 | | Yes | 1 |
    11. | utf8mb4_slovenian_ci | utf8mb4 | 228 | | Yes | 1 |
    12. | utf8mb4_polish_ci | utf8mb4 | 229 | | Yes | 1 |
    13. | utf8mb4_estonian_ci | utf8mb4 | 230 | | Yes | 1 |
    14. | utf8mb4_spanish_ci | utf8mb4 | 231 | | Yes | 1 |
    15. | utf8mb4_swedish_ci | utf8mb4 | 232 | | Yes | 1 |
    16. | utf8mb4_turkish_ci | utf8mb4 | 233 | | Yes | 1 |
    17. | utf8mb4_czech_ci | utf8mb4 | 234 | | Yes | 1 |
    18. | utf8mb4_danish_ci | utf8mb4 | 235 | | Yes | 1 |
    19. | utf8mb4_lithuanian_ci | utf8mb4 | 236 | | Yes | 1 |
    20. | utf8mb4_slovak_ci | utf8mb4 | 237 | | Yes | 1 |
    21. | utf8mb4_spanish2_ci | utf8mb4 | 238 | | Yes | 1 |
    22. | utf8mb4_roman_ci | utf8mb4 | 239 | | Yes | 1 |
    23. | utf8mb4_persian_ci | utf8mb4 | 240 | | Yes | 1 |
    24. | utf8mb4_esperanto_ci | utf8mb4 | 241 | | Yes | 1 |
    25. | utf8mb4_hungarian_ci | utf8mb4 | 242 | | Yes | 1 |
    26. | utf8mb4_sinhala_ci | utf8mb4 | 243 | | Yes | 1 |
    27. | utf8mb4_german2_ci | utf8mb4 | 244 | | Yes | 1 |
    28. | utf8mb4_croatian_ci | utf8mb4 | 245 | | Yes | 1 |
    29. | utf8mb4_unicode_520_ci | utf8mb4 | 246 | | Yes | 1 |
    30. | utf8mb4_vietnamese_ci | utf8mb4 | 247 | | Yes | 1 |
    31. +------------------------+--------------------+------+------------+-------------+---------+
    32. 26 rows in set (0.00 sec)

    COLLATION_CHARACTER_SET_APPLICABILITY Table

    COLLATION_CHARACTER_SET_APPLICABILITY 表将排序规则映射至适用的字符集名称。和 COLLATIONS 表一样,包含此表也是为了兼容 MySQL。

    1. mysql> SELECT * FROM collation_character_set_applicability WHERE character_set_name='utf8mb4';
    2. +------------------------+--------------------+
    3. | COLLATION_NAME | CHARACTER_SET_NAME |
    4. +------------------------+--------------------+
    5. | utf8mb4_general_ci | utf8mb4 |
    6. | utf8mb4_bin | utf8mb4 |
    7. | utf8mb4_unicode_ci | utf8mb4 |
    8. | utf8mb4_icelandic_ci | utf8mb4 |
    9. | utf8mb4_latvian_ci | utf8mb4 |
    10. | utf8mb4_romanian_ci | utf8mb4 |
    11. | utf8mb4_slovenian_ci | utf8mb4 |
    12. | utf8mb4_polish_ci | utf8mb4 |
    13. | utf8mb4_estonian_ci | utf8mb4 |
    14. | utf8mb4_spanish_ci | utf8mb4 |
    15. | utf8mb4_swedish_ci | utf8mb4 |
    16. | utf8mb4_turkish_ci | utf8mb4 |
    17. | utf8mb4_czech_ci | utf8mb4 |
    18. | utf8mb4_danish_ci | utf8mb4 |
    19. | utf8mb4_lithuanian_ci | utf8mb4 |
    20. | utf8mb4_slovak_ci | utf8mb4 |
    21. | utf8mb4_spanish2_ci | utf8mb4 |
    22. | utf8mb4_roman_ci | utf8mb4 |
    23. | utf8mb4_persian_ci | utf8mb4 |
    24. | utf8mb4_esperanto_ci | utf8mb4 |
    25. | utf8mb4_hungarian_ci | utf8mb4 |
    26. | utf8mb4_sinhala_ci | utf8mb4 |
    27. | utf8mb4_german2_ci | utf8mb4 |
    28. | utf8mb4_croatian_ci | utf8mb4 |
    29. | utf8mb4_unicode_520_ci | utf8mb4 |
    30. | utf8mb4_vietnamese_ci | utf8mb4 |
    31. +------------------------+--------------------+
    32. 26 rows in set (0.00 sec)

    COLUMNS Table

    COLUMNS 表提供了表的所有列的信息。

    1. mysql> CREATE TABLE test.t1 (a int);
    2. 1 row in set (0.01 sec)
    3. mysql> SELECT * FROM information_schema.columns WHERE table_schema='test' AND TABLE_NAME='t1'\G
    4. *************************** 1. row ***************************
    5. TABLE_CATALOG: def
    6. TABLE_SCHEMA: test
    7. TABLE_NAME: t1
    8. COLUMN_NAME: a
    9. ORDINAL_POSITION: 1
    10. COLUMN_DEFAULT: NULL
    11. IS_NULLABLE: YES
    12. DATA_TYPE: int
    13. CHARACTER_MAXIMUM_LENGTH: NULL
    14. CHARACTER_OCTET_LENGTH: NULL
    15. NUMERIC_PRECISION: 11
    16. NUMERIC_SCALE: 0
    17. DATETIME_PRECISION: NULL
    18. CHARACTER_SET_NAME: NULL
    19. COLLATION_NAME: NULL
    20. COLUMN_TYPE: int(11)
    21. COLUMN_KEY:
    22. EXTRA:
    23. PRIVILEGES: select,insert,update,references
    24. COLUMN_COMMENT:
    25. GENERATION_EXPRESSION:
    26. 1 row in set (0.01 sec)

    对应的 SHOW 语句如下:

    1. mysql> SHOW COLUMNS FROM t1 FROM test;
    2. +-------+---------+------+------+---------+-------+
    3. | Field | Type | Null | Key | Default | Extra |
    4. +-------+---------+------+------+---------+-------+
    5. | a | int(11) | YES | | NULL | |
    6. +-------+---------+------+------+---------+-------+
    7. 1 row in set (0.00 sec)

    ENGINES Table

    ENGINES 表提供了关于存储引擎的信息。从和 MySQL 兼容性上考虑,TiDB 会一直将 InnoDB 描述为唯一支持的引擎。

    1. mysql> SELECT * FROM engines\G
    2. *************************** 1. row ***************************
    3. ENGINE: InnoDB
    4. SUPPORT: DEFAULT
    5. COMMENT: Supports transactions, row-level locking, and foreign keys
    6. TRANSACTIONS: YES
    7. XA: YES
    8. SAVEPOINTS: YES
    9. 1 row in set (0.00 sec)

    KEY_COLUMN_USAGE Table

    KEY_COLUMN_USAGE 表描述了列的键约束,比如主键约束。

    1. mysql> SELECT * FROM key_column_usage WHERE table_schema='mysql' and table_name='user'\G
    2. *************************** 1. row ***************************
    3. CONSTRAINT_CATALOG: def
    4. CONSTRAINT_SCHEMA: mysql
    5. CONSTRAINT_NAME: PRIMARY
    6. TABLE_CATALOG: def
    7. TABLE_SCHEMA: mysql
    8. TABLE_NAME: user
    9. COLUMN_NAME: Host
    10. ORDINAL_POSITION: 1
    11. POSITION_IN_UNIQUE_CONSTRAINT: NULL
    12. REFERENCED_TABLE_SCHEMA: NULL
    13. REFERENCED_TABLE_NAME: NULL
    14. REFERENCED_COLUMN_NAME: NULL
    15. *************************** 2. row ***************************
    16. CONSTRAINT_CATALOG: def
    17. CONSTRAINT_SCHEMA: mysql
    18. CONSTRAINT_NAME: PRIMARY
    19. TABLE_CATALOG: def
    20. TABLE_SCHEMA: mysql
    21. TABLE_NAME: user
    22. COLUMN_NAME: User
    23. ORDINAL_POSITION: 2
    24. POSITION_IN_UNIQUE_CONSTRAINT: NULL
    25. REFERENCED_TABLE_SCHEMA: NULL
    26. REFERENCED_TABLE_NAME: NULL
    27. REFERENCED_COLUMN_NAME: NULL
    28. 2 rows in set (0.00 sec)

    PROCESSLIST Table

    PROCESSLISTshow processlist 的功能一样,都是查看当前正在处理的请求。

    PROCESSLIST 表会比 show processlist 多一个 MEM 列,MEM 是指正在处理的请求已使用的内存,单位是 byte。

    1. +----+------+------+--------------------+---------+------+-------+---------------------------+-----+
    2. | ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO | MEM |
    3. +----+------+------+--------------------+---------+------+-------+---------------------------+-----+
    4. | 1 | root | ::1 | INFORMATION_SCHEMA | Query | 0 | 2 | select * from PROCESSLIST | 0 |
    5. +----+------+------+--------------------+---------+------+-------+---------------------------+-----+

    SCHEMATA Table

    SCHEMATA 表提供了关于数据库的信息。表中的数据与 SHOW DATABASES 语句的执行结果等价。

    1. mysql> SELECT * FROM schemata;
    2. +--------------+--------------------+----------------------------+------------------------+----------+
    3. | CATALOG_NAME | SCHEMA_NAME | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME | SQL_PATH |
    4. +--------------+--------------------+----------------------------+------------------------+----------+
    5. | def | INFORMATION_SCHEMA | utf8mb4 | utf8mb4_bin | NULL |
    6. | def | mynewdb | utf8mb4 | utf8mb4_bin | NULL |
    7. | def | mysql | utf8mb4 | utf8mb4_bin | NULL |
    8. | def | PERFORMANCE_SCHEMA | utf8mb4 | utf8mb4_bin | NULL |
    9. | def | test | utf8mb4 | utf8mb4_bin | NULL |
    10. +--------------+--------------------+----------------------------+------------------------+----------+
    11. 5 rows in set (0.00 sec)

    SESSION_VARIABLES Table

    SESSION_VARIABLES 表提供了关于 session 变量的信息。表中的数据跟 SHOW SESSION VARIABLES 语句执行结果类似。

    1. mysql> SELECT * FROM session_variables LIMIT 10;
    2. +----------------------------------+----------------------+
    3. | VARIABLE_NAME | VARIABLE_VALUE |
    4. +----------------------------------+----------------------+
    5. | max_write_lock_count | 18446744073709551615 |
    6. | server_id_bits | 32 |
    7. | net_read_timeout | 30 |
    8. | innodb_online_alter_log_max_size | 134217728 |
    9. | innodb_optimize_fulltext_only | OFF |
    10. | max_join_size | 18446744073709551615 |
    11. | innodb_read_io_threads | 4 |
    12. | session_track_gtids | OFF |
    13. | have_ssl | DISABLED |
    14. | max_binlog_cache_size | 18446744073709547520 |
    15. +----------------------------------+----------------------+
    16. 10 rows in set (0.00 sec)

    SLOW_QUERY Table

    SLOW_QUERY 提供了慢查询相关的一些信息。表里面的内容是通过解析 TiDB 慢日志文件的数据而来的,表中列名和慢日志中的字段名是一一对应的关系。更多操作可以参考慢查询日志文档。

    1. mysql>desc SLOW_QUERY;
    2. +---------------+---------------------+------+-----+---------+-------+
    3. | Field | Type | Null | Key | Default | Extra |
    4. +---------------+---------------------+------+-----+---------+-------+
    5. | Time | timestamp unsigned | YES | | <null> | |
    6. | Txn_start_ts | bigint(20) unsigned | YES | | <null> | |
    7. | User | varchar(64) | YES | | <null> | |
    8. | Host | varchar(64) | YES | | <null> | |
    9. | Conn_ID | bigint(20) unsigned | YES | | <null> | |
    10. | Query_time | double unsigned | YES | | <null> | |
    11. | Process_time | double unsigned | YES | | <null> | |
    12. | Wait_time | double unsigned | YES | | <null> | |
    13. | Backoff_time | double unsigned | YES | | <null> | |
    14. | Request_count | bigint(20) unsigned | YES | | <null> | |
    15. | Total_keys | bigint(20) unsigned | YES | | <null> | |
    16. | Process_keys | bigint(20) unsigned | YES | | <null> | |
    17. | DB | varchar(64) | YES | | <null> | |
    18. | Index_ids | varchar(100) | YES | | <null> | |
    19. | Is_internal | tinyint(1) unsigned | YES | | <null> | |
    20. | Digest | varchar(64) | YES | | <null> | |
    21. | Stats | varchar(512) | YES | | <null> | |
    22. | Cop_proc_avg | double unsigned | YES | | <null> | |
    23. | Cop_proc_p90 | double unsigned | YES | | <null> | |
    24. | Cop_proc_max | double unsigned | YES | | <null> | |
    25. | Cop_proc_addr | varchar(64) | YES | | <null> | |
    26. | Cop_wait_avg | double unsigned | YES | | <null> | |
    27. | Cop_wait_p90 | double unsigned | YES | | <null> | |
    28. | Cop_wait_max | double unsigned | YES | | <null> | |
    29. | Cop_wait_addr | varchar(64) | YES | | <null> | |
    30. | Mem_max | bigint(20) unsigned | YES | | <null> | |
    31. | Query | varchar(4096) | YES | | <null> | |
    32. +---------------+---------------------+------+-----+---------+-------+

    STATISTICS Table

    STATISTICS 表提供了关于表索引的信息。

    1. mysql> desc statistics;
    2. +---------------|---------------------|------|------|---------|-------+
    3. | Field | Type | Null | Key | Default | Extra |
    4. +---------------|---------------------|------|------|---------|-------+
    5. | TABLE_CATALOG | varchar(512) | YES | | NULL | |
    6. | TABLE_SCHEMA | varchar(64) | YES | | NULL | |
    7. | TABLE_NAME | varchar(64) | YES | | NULL | |
    8. | NON_UNIQUE | varchar(1) | YES | | NULL | |
    9. | INDEX_SCHEMA | varchar(64) | YES | | NULL | |
    10. | INDEX_NAME | varchar(64) | YES | | NULL | |
    11. | SEQ_IN_INDEX | bigint(2) UNSIGNED | YES | | NULL | |
    12. | COLUMN_NAME | varchar(21) | YES | | NULL | |
    13. | COLLATION | varchar(1) | YES | | NULL | |
    14. | CARDINALITY | bigint(21) UNSIGNED | YES | | NULL | |
    15. | SUB_PART | bigint(3) UNSIGNED | YES | | NULL | |
    16. | PACKED | varchar(10) | YES | | NULL | |
    17. | NULLABLE | varchar(3) | YES | | NULL | |
    18. | INDEX_TYPE | varchar(16) | YES | | NULL | |
    19. | COMMENT | varchar(16) | YES | | NULL | |
    20. | INDEX_COMMENT | varchar(1024) | YES | | NULL | |
    21. +---------------|---------------------|------|------|---------|-------+

    下列语句是等价的:

    1. SELECT * FROM INFORMATION_SCHEMA.STATISTICS
    2. WHERE table_name = 'tbl_name'
    3. AND table_schema = 'db_name'
    4. SHOW INDEX
    5. FROM tbl_name
    6. FROM db_name

    TABLES Table

    TABLES 表提供了数据库里面关于表的信息。

    1. mysql> SELECT * FROM tables WHERE table_schema='mysql' AND table_name='user'\G
    2. *************************** 1. row ***************************
    3. TABLE_CATALOG: def
    4. TABLE_SCHEMA: mysql
    5. TABLE_NAME: user
    6. TABLE_TYPE: BASE TABLE
    7. ENGINE: InnoDB
    8. VERSION: 10
    9. ROW_FORMAT: Compact
    10. TABLE_ROWS: 0
    11. AVG_ROW_LENGTH: 0
    12. DATA_LENGTH: 0
    13. MAX_DATA_LENGTH: 0
    14. INDEX_LENGTH: 0
    15. DATA_FREE: 0
    16. AUTO_INCREMENT: 0
    17. CREATE_TIME: 2019-03-29 09:17:27
    18. UPDATE_TIME: NULL
    19. CHECK_TIME: NULL
    20. TABLE_COLLATION: utf8mb4_bin
    21. CHECKSUM: NULL
    22. CREATE_OPTIONS:
    23. TABLE_COMMENT:
    24. TIDB_TABLE_ID: 5
    25. 1 row in set (0.00 sec)

    以下操作是等价的:

    1. SELECT table_name FROM INFORMATION_SCHEMA.TABLES
    2. WHERE table_schema = 'db_name'
    3. [AND table_name LIKE 'wild']
    4. SHOW TABLES
    5. FROM db_name
    6. [LIKE 'wild']

    TABLE_CONSTRAINTS Table

    TABLE_CONSTRAINTS 表记录了表的约束信息。

    1. mysql> SELECT * FROM table_constraints WHERE constraint_type='UNIQUE'\G
    2. *************************** 1. row ***************************
    3. CONSTRAINT_CATALOG: def
    4. CONSTRAINT_SCHEMA: mysql
    5. CONSTRAINT_NAME: name
    6. TABLE_SCHEMA: mysql
    7. TABLE_NAME: help_topic
    8. CONSTRAINT_TYPE: UNIQUE
    9. *************************** 2. row ***************************
    10. CONSTRAINT_CATALOG: def
    11. CONSTRAINT_SCHEMA: mysql
    12. CONSTRAINT_NAME: tbl
    13. TABLE_SCHEMA: mysql
    14. TABLE_NAME: stats_meta
    15. CONSTRAINT_TYPE: UNIQUE
    16. *************************** 3. row ***************************
    17. CONSTRAINT_CATALOG: def
    18. CONSTRAINT_SCHEMA: mysql
    19. CONSTRAINT_NAME: tbl
    20. TABLE_SCHEMA: mysql
    21. TABLE_NAME: stats_histograms
    22. CONSTRAINT_TYPE: UNIQUE
    23. *************************** 4. row ***************************
    24. CONSTRAINT_CATALOG: def
    25. CONSTRAINT_SCHEMA: mysql
    26. CONSTRAINT_NAME: tbl
    27. TABLE_SCHEMA: mysql
    28. TABLE_NAME: stats_buckets
    29. CONSTRAINT_TYPE: UNIQUE
    30. *************************** 5. row ***************************
    31. CONSTRAINT_CATALOG: def
    32. CONSTRAINT_SCHEMA: mysql
    33. CONSTRAINT_NAME: delete_range_index
    34. TABLE_SCHEMA: mysql
    35. TABLE_NAME: gc_delete_range
    36. CONSTRAINT_TYPE: UNIQUE
    37. *************************** 6. row ***************************
    38. CONSTRAINT_CATALOG: def
    39. CONSTRAINT_SCHEMA: mysql
    40. CONSTRAINT_NAME: delete_range_done_index
    41. TABLE_SCHEMA: mysql
    42. TABLE_NAME: gc_delete_range_done
    43. CONSTRAINT_TYPE: UNIQUE
    44. 6 rows in set (0.00 sec)

    其中:

    • CONSTRAINT_TYPE 的取值可以是 UNIQUEPRIMARY KEY,或者 FOREIGN KEY
    • UNIQUEPRIMARY KEY 信息与 SHOW INDEX 语句的执行结果类似。

    TIDB_HOT_REGIONS Table

    TIDB_HOT_REGIONS 表提供了关于热点 REGION 的相关信息。

    1. mysql> desc TIDB_HOT_REGIONS;
    2. +----------------+---------------------+------+-----+---------+-------+
    3. | Field | Type | Null | Key | Default | Extra |
    4. +----------------+---------------------+------+-----+---------+-------+
    5. | TABLE_ID | bigint(21) unsigned | YES | | <null> | |
    6. | INDEX_ID | bigint(21) unsigned | YES | | <null> | |
    7. | DB_NAME | varchar(64) | YES | | <null> | |
    8. | TABLE_NAME | varchar(64) | YES | | <null> | |
    9. | INDEX_NAME | varchar(64) | YES | | <null> | |
    10. | TYPE | varchar(64) | YES | | <null> | |
    11. | MAX_HOT_DEGREE | bigint(21) unsigned | YES | | <null> | |
    12. | REGION_COUNT | bigint(21) unsigned | YES | | <null> | |
    13. | FLOW_BYTES | bigint(21) unsigned | YES | | <null> | |
    14. +----------------+---------------------+------+-----+---------+-------+

    TIDB_INDEXES Table

    TIDB_INDEXES 记录了所有表中的 INDEX 信息。

    1. mysql>desc TIDB_INDEXES;
    2. +---------------+---------------------+------+-----+---------+-------+
    3. | Field | Type | Null | Key | Default | Extra |
    4. +---------------+---------------------+------+-----+---------+-------+
    5. | TABLE_SCHEMA | varchar(64) | YES | | <null> | |
    6. | TABLE_NAME | varchar(64) | YES | | <null> | |
    7. | NON_UNIQUE | bigint(21) unsigned | YES | | <null> | |
    8. | KEY_NAME | varchar(64) | YES | | <null> | |
    9. | SEQ_IN_INDEX | bigint(21) unsigned | YES | | <null> | |
    10. | COLUMN_NAME | varchar(64) | YES | | <null> | |
    11. | SUB_PART | bigint(21) unsigned | YES | | <null> | |
    12. | INDEX_COMMENT | varchar(2048) | YES | | <null> | |
    13. | INDEX_ID | bigint(21) unsigned | YES | | <null> | |
    14. +---------------+---------------------+------+-----+---------+-------+

    TIKV_REGION_PEERS Table

    TIKV_REGION_PEERS 表提供了所有 REGION 的 peer 信息。

    1. mysql> desc TIKV_REGION_PEERS;
    2. +--------------+---------------------+------+-----+---------+-------+
    3. | Field | Type | Null | Key | Default | Extra |
    4. +--------------+---------------------+------+-----+---------+-------+
    5. | REGION_ID | bigint(21) unsigned | YES | | <null> | |
    6. | PEER_ID | bigint(21) unsigned | YES | | <null> | |
    7. | STORE_ID | bigint(21) unsigned | YES | | <null> | |
    8. | IS_LEARNER | tinyint(1) unsigned | YES | | <null> | |
    9. | IS_LEADER | tinyint(1) unsigned | YES | | <null> | |
    10. | STATUS | varchar(10) | YES | | <null> | |
    11. | DOWN_SECONDS | bigint(21) unsigned | YES | | <null> | |
    12. +--------------+---------------------+------+-----+---------+-------+

    TIKV_REGION_STATUS Table

    TIKV_REGION_STATUS 表提供了所有 REGION 的状态信息。

    1. mysql> desc TIKV_REGION_STATUS;
    2. +------------------+---------------------+------+-----+---------+-------+
    3. | Field | Type | Null | Key | Default | Extra |
    4. +------------------+---------------------+------+-----+---------+-------+
    5. | REGION_ID | bigint(21) unsigned | YES | | <null> | |
    6. | START_KEY | text | YES | | <null> | |
    7. | END_KEY | text | YES | | <null> | |
    8. | EPOCH_CONF_VER | bigint(21) unsigned | YES | | <null> | |
    9. | EPOCH_VERSION | bigint(21) unsigned | YES | | <null> | |
    10. | WRITTEN_BYTES | bigint(21) unsigned | YES | | <null> | |
    11. | READ_BYTES | bigint(21) unsigned | YES | | <null> | |
    12. | APPROXIMATE_SIZE | bigint(21) unsigned | YES | | <null> | |
    13. | APPROXIMATE_KEYS | bigint(21) unsigned | YES | | <null> | |
    14. +------------------+---------------------+------+-----+---------+-------+

    TIKV_STORE_STATUS Table

    TIKV_STORE_STATUS 表提供了所有 TiKV Store 的状态信息。

    1. mysql> desc TIKV_STORE_STATUS;
    2. +-------------------+---------------------+------+-----+---------+-------+
    3. | Field | Type | Null | Key | Default | Extra |
    4. +-------------------+---------------------+------+-----+---------+-------+
    5. | STORE_ID | bigint(21) unsigned | YES | | <null> | |
    6. | ADDRESS | varchar(64) | YES | | <null> | |
    7. | STORE_STATE | bigint(21) unsigned | YES | | <null> | |
    8. | STORE_STATE_NAME | varchar(64) | YES | | <null> | |
    9. | LABEL | json unsigned | YES | | <null> | |
    10. | VERSION | varchar(64) | YES | | <null> | |
    11. | CAPACITY | varchar(64) | YES | | <null> | |
    12. | AVAILABLE | varchar(64) | YES | | <null> | |
    13. | LEADER_COUNT | bigint(21) unsigned | YES | | <null> | |
    14. | LEADER_WEIGHT | bigint(21) unsigned | YES | | <null> | |
    15. | LEADER_SCORE | bigint(21) unsigned | YES | | <null> | |
    16. | LEADER_SIZE | bigint(21) unsigned | YES | | <null> | |
    17. | REGION_COUNT | bigint(21) unsigned | YES | | <null> | |
    18. | REGION_WEIGHT | bigint(21) unsigned | YES | | <null> | |
    19. | REGION_SCORE | bigint(21) unsigned | YES | | <null> | |
    20. | REGION_SIZE | bigint(21) unsigned | YES | | <null> | |
    21. | START_TS | datetime unsigned | YES | | <null> | |
    22. | LAST_HEARTBEAT_TS | datetime unsigned | YES | | <null> | |
    23. | UPTIME | varchar(64) | YES | | <null> | |
    24. +-------------------+---------------------+------+-----+---------+-------+

    USER_PRIVILEGES Table

    USER_PRIVILEGES 表提供了关于全局权限的信息。该表的数据根据 mysql.user 系统表生成。

    1. mysql> desc USER_PRIVILEGES;
    2. +----------------|--------------|------|------|---------|-------+
    3. | Field | Type | Null | Key | Default | Extra |
    4. +----------------|--------------|------|------|---------|-------+
    5. | GRANTEE | varchar(81) | YES | | NULL | |
    6. | TABLE_CATALOG | varchar(512) | YES | | NULL | |
    7. | PRIVILEGE_TYPE | varchar(64) | YES | | NULL | |
    8. | IS_GRANTABLE | varchar(3) | YES | | NULL | |
    9. +----------------|--------------|------|------|---------|-------+
    10. 4 rows in set (0.00 sec)

    VIEWS Table

    VIEWS 表提供了关于 SQL 视图的信息。

    1. mysql> create view test.v1 as select 1;
    2. Query OK, 0 rows affected (0.00 sec)
    3. mysql> select * from views\G
    4. *************************** 1. row ***************************
    5. TABLE_CATALOG: def
    6. TABLE_SCHEMA: test
    7. TABLE_NAME: v1
    8. VIEW_DEFINITION: select 1
    9. CHECK_OPTION: CASCADED
    10. IS_UPDATABLE: NO
    11. DEFINER: root@127.0.0.1
    12. SECURITY_TYPE: DEFINER
    13. CHARACTER_SET_CLIENT: utf8
    14. COLLATION_CONNECTION: utf8_general_ci
    15. 1 row in set (0.00 sec)

    不支持的 Information Schema 表

    TiDB 包含以下 INFORMATION_SCHEMA 表,但仅会返回空行:

    • COLUMN_PRIVILEGES
    • EVENTS
    • FILES
    • GLOBAL_STATUS
    • GLOBAL_VARIABLES
    • OPTIMIZER_TRACE
    • PARAMETERS
    • PARTITIONS
    • PLUGINS
    • PROFILING
    • REFERENTIAL_CONSTRAINTS
    • ROUTINES
    • SCHEMA_PRIVILEGES
    • SESSION_STATUS
    • TABLESPACES
    • TABLE_PRIVILEGES
    • TRIGGERS