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. | engine | String | | YES | | FIELD |
  10. +---------------+--------+------+------+---------+---------------+
  11. 6 rows in set (0.00 sec)
  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: 1025
  7. engine: mito
  8. 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:该表使用的存储引擎。