TABLES

TABLES 表提供数据库中表的信息:

  1. USE INFORMATION_SCHEMA;
  2. DESC TABLES;

结果如下:

  1. +------------------+----------+------+------+---------+---------------+
  2. | Column | Type | Key | Null | Default | Semantic Type |
  3. +------------------+----------+------+------+---------+---------------+
  4. | table_catalog | String | | NO | | FIELD |
  5. | table_schema | String | | NO | | FIELD |
  6. | table_name | String | | NO | | FIELD |
  7. | table_type | String | | NO | | FIELD |
  8. | table_id | UInt32 | | YES | | FIELD |
  9. | data_length | UInt64 | | YES | | FIELD |
  10. | max_data_length | UInt64 | | YES | | FIELD |
  11. | index_length | UInt64 | | YES | | FIELD |
  12. | max_index_length | UInt64 | | YES | | FIELD |
  13. | avg_row_length | UInt64 | | YES | | FIELD |
  14. | engine | String | | YES | | FIELD |
  15. | version | UInt64 | | YES | | FIELD |
  16. | row_format | String | | YES | | FIELD |
  17. | table_rows | UInt64 | | YES | | FIELD |
  18. | data_free | UInt64 | | YES | | FIELD |
  19. | auto_increment | UInt64 | | YES | | FIELD |
  20. | create_time | DateTime | | YES | | FIELD |
  21. | update_time | DateTime | | YES | | FIELD |
  22. | check_time | DateTime | | YES | | FIELD |
  23. | table_collation | String | | YES | | FIELD |
  24. | checksum | UInt64 | | YES | | FIELD |
  25. | create_options | String | | YES | | FIELD |
  26. | table_comment | String | | YES | | FIELD |
  27. | temporary | String | | YES | | FIELD |
  28. +------------------+----------+------+------+---------+---------------+
  1. SELECT * FROM tables WHERE table_schema='public' AND table_name='monitor'\G
  1. *************************** 1. row ***************************
  2. table_catalog: greptime
  3. table_schema: public
  4. table_name: monitor
  5. table_type: BASE TABLE
  6. table_id: 1054
  7. data_length: 0
  8. max_data_length: 0
  9. index_length: 0
  10. max_index_length: 0
  11. avg_row_length: 0
  12. engine: mito
  13. version: 11
  14. row_format: Fixed
  15. table_rows: 0
  16. data_free: 0
  17. auto_increment: 0
  18. create_time: 2024-07-24 22:06:18.085000
  19. update_time: NULL
  20. check_time: NULL
  21. table_collation: NULL
  22. checksum: 0
  23. create_options:
  24. table_comment: NULL
  25. temporary: N
  26. 1 row in set (0.01 sec)

下方的语句是等价的:

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

TABLES 表的字段描述如下:

  • table_catalog:表所属的目录。该值始终为 greptime
  • table_schema:表所属的数据库。
  • table_name:表的名称。
  • table_type:表的类型。
    • BASE TABLE:基础表
    • TEMPORARY:临时结果集
    • VIEW:视图表
  • table_id:表 ID。
  • engine:该表使用的存储引擎。
  • version: 版本。固定值为 11
  • create_time: 表创建的时间戳。
  • table_comment: 表的注释。
  • 其他列如 table_rowsrow_format 等不支持,仅用于兼容 MySQL。GreptimeDB 未来可能会支持其中的一些列。