系统表

IoTDB 内置系统数据库 INFORMATION_SCHEMA,其中包含一系列系统表,用于存储 IoTDB 运行时信息(如当前正在执行的 SQL 语句等)。目前INFORMATION_SCHEMA数据库只支持读操作。

1. 系统库

  • 名称:INFORMATION_SCHEMA
  • 指令:只读,只支持 Show databases (DETAILS) / Show Tables (DETAILS) / Use,其余操作将会报错:"The database 'information_schema' can only be queried"
  • 属性:TTL=INF,其余属性默认为null
  • SQL示例:
IoTDB> show databases
+------------------+-------+-----------------------+---------------------+---------------------+
|          Database|TTL(ms)|SchemaReplicationFactor|DataReplicationFactor|TimePartitionInterval|
+------------------+-------+-----------------------+---------------------+---------------------+
|information_schema|    INF|                   null|                 null|                 null|
+------------------+-------+-----------------------+---------------------+---------------------+

IoTDB> show tables from information_schema
+-------------+-------+
|    TableName|TTL(ms)|
+-------------+-------+
|    databases|    INF|
|       tables|    INF|
| pipe_plugins|    INF|
|subscriptions|    INF|
|      regions|    INF|
|      columns|    INF|
|       topics|    INF|
|      queries|    INF|
|        pipes|    INF|
+-------------+-------+

2. 系统表

  • 名称:DATABASES, TABLES, REGIONS, QUERIES, COLUMNS, PIPES, PIPE_PLUGINS, SUBSCRIPTION, TOPICS(详细介绍见后面小节)
  • 操作:只读,只支持SELECT, COUNT/SHOW DEVICES, DESC,不支持对于表结构 / 内容的任意修改,如果修改将会报错:"The database 'information_schema' can only be queried"
  • 列名:系统表的列名均默认为小写,且用_分隔

2.1 DATABASES 表

  • 包含集群中所有数据库的信息
  • 表结构如下表所示:
列名数据类型列类型说明
databaseSTRINGTAG数据库名称
ttl(ms)STRINGATTRIBUTE数据保留时间
schema_replication_factorINT32ATTRIBUTE元数据副本数
data_replication_factorINT32ATTRIBUTE数据副本数
time_partition_intervalINT64ATTRIBUTE时间分区间隔
schema_region_group_numINT32ATTRIBUTE元数据分区数量
data_region_group_numINT32ATTRIBUTE数据分区数量
  • 查询示例:
IoTDB> select * from information_schema.databases
+------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------+
|          database|ttl(ms)|schema_replication_factor|data_replication_factor|time_partition_interval|schema_region_group_num|data_region_group_num|
+------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------+
|information_schema|    INF|                     null|                   null|                   null|                   null|                 null|
|         database1|    INF|                        1|                      1|              604800000|                      0|                    0|
+------------------+-------+-------------------------+-----------------------+-----------------------+-----------------------+---------------------+

2.2 TABLES 表

  • 包含集群中所有表的信息
  • 表结构如下表所示:
列名数据类型列类型说明
databaseSTRINGTAG数据库名称
table_nameSTRINGTAG表名称
ttl(ms)STRINGATTRIBUTE数据保留时间
statusSTRINGATTRIBUTE状态
commentSTRINGATTRIBUTE注释
  • 说明:status 可能为USING/PRE_CREATE/PRE_DELETE,具体见表管理中查看表的相关描述
  • 查询示例:
IoTDB> select * from information_schema.tables
+------------------+-------------+-----------+------+-------+
|          database|   table_name|    ttl(ms)|status|comment|
+------------------+-------------+-----------+------+-------+
|information_schema|    databases|        INF| USING|   null|
|information_schema|       tables|        INF| USING|   null|
|information_schema| pipe_plugins|        INF| USING|   null|
|information_schema|subscriptions|        INF| USING|   null|
|information_schema|      regions|        INF| USING|   null|
|information_schema|      columns|        INF| USING|   null|
|information_schema|       topics|        INF| USING|   null|
|information_schema|      queries|        INF| USING|   null|
|information_schema|        pipes|        INF| USING|   null|
|         database1|       table1|31536000000| USING|   null|
+------------------+-------------+-----------+------+-------+

2.3 REGIONS 表

  • 包含集群中所有Region的信息
  • 表结构如下表所示:
列名数据类型列类型说明
region_idINT32TAGregion ID
datanode_idINT32TAGdataNode ID
typeSTRINGATTRIBUTE类型(SchemaRegion / DataRegion)
statusSTRINGATTRIBUTE状态(Running/Unknown 等)
databaseSTRINGATTRIBUTEdatabase 名字
series_slot_numINT32ATTRIBUTEseries slot 个数
time_slot_numINT64ATTRIBUTEtime slot 个数
rpc_addressSTRINGATTRIBUTERpc 地址
rpc_portINT32ATTRIBUTERpc 端口
internal_addressSTRINGATTRIBUTE内部通讯地址
roleSTRINGATTRIBUTELeader / Follower
create_timeTIMESTAMPATTRIBUTE创建时间
tsfile_size_bytesINT64ATTRIBUTE可统计的 DataRegion:含有 TsFile 的总文件大小;不可统计的 DataRegion(Unknown):-1;SchemaRegion:null;
  • 查询示例:
IoTDB> select * from information_schema.regions
+---------+-----------+------------+-------+---------+---------------+-------------+-----------+--------+----------------+------+-----------------------------+-----------------+
|region_id|datanode_id|        type| status| database|series_slot_num|time_slot_num|rpc_address|rpc_port|internal_address|  role|                  create_time|tsfile_size_bytes|
+---------+-----------+------------+-------+---------+---------------+-------------+-----------+--------+----------------+------+-----------------------------+-----------------+
|        0|          1|SchemaRegion|Running|database1|             12|            0|    0.0.0.0|    6667|       127.0.0.1|Leader|2025-03-31T11:19:08.485+08:00|             null|
|        1|          1|  DataRegion|Running|database1|              6|            6|    0.0.0.0|    6667|       127.0.0.1|Leader|2025-03-31T11:19:09.156+08:00|             3985|
|        2|          1|  DataRegion|Running|database1|              6|            6|    0.0.0.0|    6667|       127.0.0.1|Leader|2025-03-31T11:19:09.156+08:00|             3841|
+---------+-----------+------------+-------+---------+---------------+-------------+-----------+--------+----------------+------+-----------------------------+-----------------+

2.4 QUERIES 表

  • 包含集群中所有正在执行的查询的信息。也可以使用 SHOW QUERIES语法去查询。
  • 表结构如下表所示:
列名数据类型列类型说明
query_idSTRINGTAGID
start_timeTIMESTAMPATTRIBUTE查询开始的时间戳,时间戳精度与系统精度保持一致
datanode_idINT32ATTRIBUTE发起查询的DataNode ID
elapsed_timeFLOATATTRIBUTE查询执行耗时,单位是秒
statementSTRINGATTRIBUTE查询sql
userSTRINGATTRIBUTE发起查询的用户
  • 查询示例:
IoTDB> select * from information_schema.queries
+-----------------------+-----------------------------+-----------+------------+----------------------------------------+----+
|               query_id|                   start_time|datanode_id|elapsed_time|                               statement|user|
+-----------------------+-----------------------------+-----------+------------+----------------------------------------+----+
|20250331_023242_00011_1|2025-03-31T10:32:42.360+08:00|          1|       0.025|select * from information_schema.queries|root|
+-----------------------+-----------------------------+-----------+------------+----------------------------------------+----+

2.5 COLUMNS 表

  • 包含集群中所有表中列的信息
  • 表结构如下表所示:
列名数据类型列类型说明
databaseSTRINGTAG数据库名称
table_nameSTRINGTAG表名称
column_nameSTRINGTAG列名称
datatypeSTRINGATTRIBUTE列的数值类型
categorySTRINGATTRIBUTE列类型
statusSTRINGATTRIBUTE列状态
commentSTRINGATTRIBUTE列注释

说明: status 可能为USING/PRE_DELETE,具体见表管理中查看表的列的相关描述

用户只能查出自己有展示权限的 table

  • 查询示例:
IoTDB> select * from information_schema.columns where database = 'database1'
+---------+----------+------------+---------+---------+------+-------+
| database|table_name| column_name| datatype| category|status|comment|
+---------+----------+------------+---------+---------+------+-------+
|database1|    table1|        time|TIMESTAMP|     TIME| USING|   null|
|database1|    table1|      region|   STRING|      TAG| USING|   null|
|database1|    table1|    plant_id|   STRING|      TAG| USING|   null|
|database1|    table1|   device_id|   STRING|      TAG| USING|   null|
|database1|    table1|    model_id|   STRING|ATTRIBUTE| USING|   null|
|database1|    table1| maintenance|   STRING|ATTRIBUTE| USING|   null|
|database1|    table1| temperature|    FLOAT|    FIELD| USING|   null|
|database1|    table1|    humidity|    FLOAT|    FIELD| USING|   null|
|database1|    table1|      status|  BOOLEAN|    FIELD| USING|   null|
|database1|    table1|arrival_time|TIMESTAMP|    FIELD| USING|   null|
+---------+----------+------------+---------+---------+------+-------+

2.6 PIPES 表

  • 包含集群中所有 PIPE 的信息
  • 表结构如下表所示:
列名数据类型列类型说明
idSTRINGTAGPipe 名称
creation_timeTIMESTAMPATTRIBUTE创建时间
stateSTRINGATTRIBUTEPipe 状态(RUNNING/STOPPED)
pipe_sourceSTRINGATTRIBUTEsource 插件参数
pipe_processorSTRINGATTRIBUTEprocessor 插件参数
pipe_sinkSTRINGATTRIBUTEsource 插件参数
exception_messageSTRINGATTRIBUTEException 信息
remaining_event_countINT64ATTRIBUTE剩余 event 数量,如果 Unknown 则为 -1
estimated_remaining_secondsDOUBLEATTRIBUTE预估剩余时间,如果 Unknown 则为 -1
  • 查询示例:
select * from information_schema.pipes
+----------+-----------------------------+-------+--------------------------------------------------------------------------+--------------+-----------------------------------------------------------------------+-----------------+---------------------+---------------------------+
|        id|                creation_time|  state|                                                               pipe_source|pipe_processor|                                                              pipe_sink|exception_message|remaining_event_count|estimated_remaining_seconds|
+----------+-----------------------------+-------+--------------------------------------------------------------------------+--------------+-----------------------------------------------------------------------+-----------------+---------------------+---------------------------+
|tablepipe1|2025-03-31T12:25:24.040+08:00|RUNNING|{__system.sql-dialect=table, source.password=******, source.username=root}|            {}|{format=hybrid, node-urls=192.168.xxx.xxx:6667, sink=iotdb-thrift-sink}|                 |                    0|                        0.0|
+----------+-----------------------------+-------+--------------------------------------------------------------------------+--------------+-----------------------------------------------------------------------+-----------------+---------------------+---------------------------+

2.7 PIPE_PLUGINS 表

  • 包含集群中所有PIPE插件的信息
  • 表结构如下表所示:
列名数据类型列类型说明
plugin_nameSTRINGTAG插件名称
plugin_typeSTRINGATTRIBUTE插件类型(Builtin/External)
class_nameSTRINGATTRIBUTE插件的主类名
plugin_jarSTRINGATTRIBUTE插件的 jar 包名称,若为 builtin 类型则为 null
  • 查询示例:
IoTDB> select * from information_schema.pipe_plugins
+---------------------+-----------+-------------------------------------------------------------------------------------------------+----------+
|          plugin_name|plugin_type|                                                                                       class_name|plugin_jar|
+---------------------+-----------+-------------------------------------------------------------------------------------------------+----------+
|IOTDB-THRIFT-SSL-SINK|    Builtin|org.apache.iotdb.commons.pipe.agent.plugin.builtin.connector.iotdb.thrift.IoTDBThriftSslConnector|      null|
|   IOTDB-AIR-GAP-SINK|    Builtin|   org.apache.iotdb.commons.pipe.agent.plugin.builtin.connector.iotdb.airgap.IoTDBAirGapConnector|      null|
|      DO-NOTHING-SINK|    Builtin|        org.apache.iotdb.commons.pipe.agent.plugin.builtin.connector.donothing.DoNothingConnector|      null|
| DO-NOTHING-PROCESSOR|    Builtin|        org.apache.iotdb.commons.pipe.agent.plugin.builtin.processor.donothing.DoNothingProcessor|      null|
|    IOTDB-THRIFT-SINK|    Builtin|   org.apache.iotdb.commons.pipe.agent.plugin.builtin.connector.iotdb.thrift.IoTDBThriftConnector|      null|
|         IOTDB-SOURCE|    Builtin|                org.apache.iotdb.commons.pipe.agent.plugin.builtin.extractor.iotdb.IoTDBExtractor|      null|
+---------------------+-----------+-------------------------------------------------------------------------------------------------+----------+

2.8 SUBSCRIPTIONS 表

  • 包含集群中所有数据订阅的信息
  • 表结构如下表所示:
列名数据类型列类型说明
topic_nameSTRINGTAG订阅主题名称
consumer_group_nameSTRINGTAG消费者组名称
subscribed_consumersSTRINGATTRIBUTE订阅的消费者
  • 查询示例:
IoTDB> select * from information_schema.subscriptions where topic_name = 'topic_1'
+----------+-------------------+--------------------------------+
|topic_name|consumer_group_name|            subscribed_consumers|
+----------+-------------------+--------------------------------+
|   topic_1|                cg1|[c3, c4, c5, c6, c7, c0, c1, c2]|
+----------+-------------------+--------------------------------+

2.9 TOPICS 表

  • 包含集群中所有数据订阅主题的信息
  • 表结构如下表所示:
列名数据类型列类型说明
topic_nameSTRINGTAG订阅主题名称
topic_configsSTRINGATTRIBUTE订阅主题配置
  • 查询示例:
IoTDB> select * from information_schema.topics
+----------+----------------------------------------------------------------+
|topic_name|                                                   topic_configs|
+----------+----------------------------------------------------------------+
|     topic|{__system.sql-dialect=table, start-time=2025-01-10T17:05:38.282}|
+----------+----------------------------------------------------------------+

3. 权限说明

  • 不支持通过GRANT/REVOKE语句对 information_schema 数据库及其下任何表进行权限操作
  • 支持任意用户通过show databases语句查看information_schema数据库相关信息
  • 支持任意用户通过show tables from information_schema 语句查看所有系统表相关信息
  • 支持任意用户通过desc语句查看任意系统表
  • 目前只支持 root 用户通过select语句从系统表中查询数据,其他用户查询时展示空结果集