Skip to main content

Metadata

TDengine has a built-in database called INFORMATION_SCHEMA, which provides access to database metadata, system information, and status, such as the names of databases or tables, and currently executed SQL statements. This database stores information about all other databases maintained by TDengine. It contains several read-only tables. In fact, these tables are views rather than base tables, so there are no associated files with them. Therefore, you can only query these tables and cannot perform write operations such as INSERT. The INFORMATION_SCHEMA database is designed to provide access to information supported by various SHOW statements (like SHOW TABLES, SHOW DATABASES) in a more consistent manner. Compared to SHOW statements, using SELECT ... FROM INFORMATION_SCHEMA.tablename has the following advantages:

  1. You can use the USE statement to set INFORMATION_SCHEMA as the default database.
  2. You can use the familiar SELECT statement syntax, only needing to learn some table names and column names.
  3. You can filter, sort, and perform other operations on the query results. In fact, you can use any SELECT statement supported by TDengine to query the tables in INFORMATION_SCHEMA.
  4. TDengine can flexibly add columns to existing tables in INFORMATION_SCHEMA in future versions without worrying about affecting existing business systems.
  5. It is more interoperable with other database systems. For example, Oracle database users are familiar with querying the Oracle data dictionary tables.
info
  • Since SHOW statements have already been familiar and widely used by developers, they are still retained.

  • Some columns in system tables may be keywords, and you need to use the escape character '`' when querying, for example, to query how many VGROUPs database test has:

    select `vgroups` from ins_databases where name = 'test';

This chapter will detail the tables and table structures in the built-in metadata database INFORMATION_SCHEMA.

INS_DNODES

Provides information related to dnodes. You can also use SHOW DNODES to query this information. Users with SYSINFO set to 0 cannot view this table.

#Column NameData TypeDescription
1vnodesSMALLINTThe actual number of vnodes in the dnode. Note that vnodes is a TDengine keyword and needs to be escaped with `.
2support_vnodesSMALLINTThe maximum number of supported vnodes
3statusBINARY(10)The current status
4noteBINARY(256)Reason for offline and other information
5idSMALLINTdnode id
6endpointBINARY(134)The address of the dnode
7createTIMESTAMPCreation time

INS_MNODES

Provides information related to mnodes. You can also use SHOW MNODES to query this information. Users with SYSINFO set to 0 cannot view this table.

#Column NameData TypeDescription
1idSMALLINTmnode id
2endpointBINARY(134)The address of the mnode
3roleBINARY(10)Current role
4role_timeTIMESTAMPThe time when it became the current role
5create_timeTIMESTAMPCreation time

INS_QNODES

Information about QNODEs in the current system. You can also use SHOW QNODES to query this information. Users with SYSINFO set to 0 cannot view this table.

#Column NameData TypeDescription
1idSMALLINTqnode id
2endpointVARCHAR(134)The address of the qnode
3create_timeTIMESTAMPCreation time

INS_SNODES

Information about SNODEs in the current system. You can also use SHOW SNODES to query this information. Users with SYSINFO set to 0 cannot view this table.

#Column NameData TypeDescription
1idSMALLINTsnode id
2endpointVARCHAR(134)The address of the snode
3create_timeTIMESTAMPCreation time

INS_CLUSTER

Stores cluster-related information. Users with SYSINFO set to 0 cannot view this table.

#Column NameData TypeDescription
1idBIGINTCluster id
2nameVARCHAR(134)Cluster name
3create_timeTIMESTAMPCreation time

INS_DATABASES

Provides information about user-created database objects. You can also use SHOW DATABASES to query this information.

#Column NameData TypeDescription
1nameVARCHAR(64)Database name
2create_timeTIMESTAMPCreation time
3ntablesINTNumber of tables in the database, including subtables and basic tables but excluding supertables
4vgroupsINTNumber of vgroups in the database. Note that vgroups is a TDengine keyword and needs to be escaped with `.
5replicaINTNumber of replicas. Note that replica is a TDengine keyword and needs to be escaped with `.
6strictVARCHAR(4)Deprecated parameter
7durationVARCHAR(10)Duration of time data is stored in a single file. Note that duration is a TDengine keyword and needs to be escaped with `. The internal storage unit is minutes, and it may be converted to days or hours during queries.
8keepVARCHAR(32)Data retention duration. Note that keep is a TDengine keyword and needs to be escaped with `. The internal storage unit is minutes, and it may be converted to days or hours during queries.
9bufferINTSize of the memory block for writing caches per vnode, in MB. Note that buffer is a TDengine keyword and needs to be escaped with `.
10pagesizeINTPage size of the metadata storage engine in each VNODE, in KB. Note that pagesize is a TDengine keyword and needs to be escaped with `.
11pagesINTNumber of cached pages for metadata storage engine in each vnode. Note that pages is a TDengine keyword and needs to be escaped with `.
12minrowsINTMinimum number of records in a file block. Note that minrows is a TDengine keyword and needs to be escaped with `.
13maxrowsINTMaximum number of records in a file block. Note that maxrows is a TDengine keyword and needs to be escaped with `.
14compINTData compression method. Note that comp is a TDengine keyword and needs to be escaped with `.
15precisionVARCHAR(2)Time resolution. Note that precision is a TDengine keyword and needs to be escaped with `.
16statusVARCHAR(10)Database status
17retentionsVARCHAR(60)Data aggregation cycle and retention duration. Note that retentions is a TDengine keyword and needs to be escaped with `.
18single_stableBOOLIndicates whether only one supertable can be created in this database. Note that single_stable is a TDengine keyword and needs to be escaped with `.
19cachemodelVARCHAR(60)Indicates whether to cache the most recent data of subtables in memory. Note that cachemodel is a TDengine keyword and needs to be escaped with `.
20cachesizeINTSize of memory used for caching the most recent data of subtables in each vnode. Note that cachesize is a TDengine keyword and needs to be escaped with `.
21wal_levelINTWAL level. Note that wal_level is a TDengine keyword and needs to be escaped with `.
22wal_fsync_periodINTData persistence period. Note that wal_fsync_period is a TDengine keyword and needs to be escaped with `.
23wal_retention_periodINTWAL retention duration, in seconds. Note that wal_retention_period is a TDengine keyword and needs to be escaped with `.
24wal_retention_sizeINTWAL retention limit. Note that wal_retention_size is a TDengine keyword and needs to be escaped with `.
25stt_triggerSMALLINTNumber of persistent files that trigger file merging. Note that stt_trigger is a TDengine keyword and needs to be escaped with `.
26table_prefixSMALLINTLength of prefix to ignore when assigning storage of table data by table name in the internal storage engine. Note that table_prefix is a TDengine keyword and needs to be escaped with `.
27table_suffixSMALLINTLength of suffix to ignore when assigning storage of table data by table name in the internal storage engine. Note that table_suffix is a TDengine keyword and needs to be escaped with `.
28tsdb_pagesizeINTPage size in the time-series data storage engine. Note that tsdb_pagesize is a TDengine keyword and needs to be escaped with `.

INS_FUNCTIONS

Information about user-created custom functions.

#Column NameData TypeDescription
1nameVARCHAR(64)Function name
2commentVARCHAR(255)Additional description. Note that comment is a TDengine keyword and needs to be escaped with `.
3aggregateINTIndicates whether it is an aggregate function. Note that aggregate is a TDengine keyword and needs to be escaped with `.
4output_typeVARCHAR(31)Output type
5create_timeTIMESTAMPCreation time
6code_lenINTCode length
7bufsizeINTBuffer size
8func_languageVARCHAR(31)Programming language of the custom function
9func_bodyVARCHAR(16384)Function body definition
10func_versionINTFunction version number. Initial version is 0, and each update increments the version number.

INS_INDEXES

Provides information related to indexes created by users. You can also use SHOW INDEX to query this information.

#Column NameData TypeDescription
1db_nameVARCHAR(32)Database name containing this index
2table_nameVARCHAR(192)Name of the table containing this index
3index_nameVARCHAR(192)Index name
4column_nameVARCHAR(64)Name of the column indexed
5index_typeVARCHAR(10)Currently, there are SMA and tag
6index_extensionsVARCHAR(256)Additional information about the index. For SMA/tag indexes, this is a list of function names.

INS_STABLES

Provides information about supertables created by users.

#Column NameData TypeDescription
1stable_nameVARCHAR(192)Supertable name
2db_nameVARCHAR(64)Name of the database where the supertable is located
3create_timeTIMESTAMPCreation time
4columnsINTNumber of columns
5tagsINTNumber of tags. Note that tags is a TDengine keyword and needs to be escaped with `.
6last_updateTIMESTAMPLast update time
7table_commentVARCHAR(1024)Table comment
8watermarkVARCHAR(64)Window closing time. Note that watermark is a TDengine keyword and needs to be escaped with `.
9max_delayVARCHAR(64)Maximum delay for pushing computation results. Note that max_delay is a TDengine keyword and needs to be escaped with `.
10rollupVARCHAR(128)Rollup aggregation function. Note that rollup is a TDengine keyword and needs to be escaped with `.

INS_TABLES

Provides information about basic tables and subtables created by users.

#Column NameData TypeDescription
1table_nameVARCHAR(192)Table name
2db_nameVARCHAR(64)Name of the database where the table is located
3create_timeTIMESTAMPCreation time
4columnsINTNumber of columns
5stable_nameVARCHAR(192)Name of the supertable to which it belongs
6uidBIGINTTable id
7vgroup_idINTvgroup id
8ttlINTLifecycle of the table. Note that ttl is a TDengine keyword and needs to be escaped with `.
9table_commentVARCHAR(1024)Table comment
10typeVARCHAR(21)Table type

INS_TAGS

#Column NameData TypeDescription
1table_nameVARCHAR(192)Table name
2db_nameVARCHAR(64)Name of the database where this table is located
3stable_nameVARCHAR(192)Name of the supertable to which it belongs
4tag_nameVARCHAR(64)Name of the tag
5tag_typeVARCHAR(64)Type of the tag
6tag_valueVARCHAR(16384)Value of the tag

INS_COLUMNS

#Column NameData TypeDescription
1table_nameVARCHAR(192)Table name
2db_nameVARCHAR(64)Name of the database where this table is located
3table_typeVARCHAR(21)Table type
4col_nameVARCHAR(64)Name of the column
5col_typeVARCHAR(32)Type of the column
6col_lengthINTLength of the column
7col_precisionINTPrecision of the column
8col_scaleINTScale of the column
9col_nullableINTIndicates whether the column can be null

INS_USERS

Provides information about users created in the system. Users with SYSINFO set to 0 cannot view this table.

#Column NameData TypeDescription
1nameVARCHAR(24)Username
2superTINYINTWhether the user is a superuser, 1: yes, 0: no
3enableTINYINTWhether the user is enabled, 1: yes, 0: no
4sysinfoTINYINTWhether the user can view system information, 1: yes, 0: no
5create_timeTIMESTAMPCreation time
6allowed_hostVARCHAR(49152)IP whitelist

INS_GRANTS

Provides information about enterprise edition authorizations. Users with SYSINFO set to 0 cannot view this table.

#Column NameData TypeDescription
1versionVARCHAR(9)Enterprise edition authorization description: official (officially authorized) / trial (trial version)
2cpu_coresVARCHAR(9)Number of CPU cores authorized for use
3dnodesVARCHAR(10)Number of dnode nodes authorized for use. Note that dnodes is a TDengine keyword and needs to be escaped with `.
4streamsVARCHAR(10)Number of streams authorized for creation. Note that streams is a TDengine keyword and needs to be escaped with `.
5usersVARCHAR(10)Number of users authorized for creation. Note that users is a TDengine keyword and needs to be escaped with `.
6accountsVARCHAR(10)Number of accounts authorized for creation. Note that accounts is a TDengine keyword and needs to be escaped with `.
7storageVARCHAR(21)Size of storage space authorized for use. Note that storage is a TDengine keyword and needs to be escaped with `.
8connectionsVARCHAR(21)Number of client connections authorized for use. Note that connections is a TDengine keyword and needs to be escaped with `.
9databasesVARCHAR(11)Number of databases authorized for use. Note that databases is a TDengine keyword and needs to be escaped with `.
10speedVARCHAR(9)Number of data points per second authorized for use
11querytimeVARCHAR(9)Total duration for queries authorized for use
12timeseriesVARCHAR(21)Number of measurement points authorized for use
13expiredVARCHAR(5)Whether it has expired, true: expired, false: not expired
14expire_timeVARCHAR(19)Trial expiration date

INS_VGROUPS

Information about all vgroups in the system. Users with SYSINFO set to 0 cannot view this table.

#Column NameData TypeDescription
1vgroup_idINTvgroup id
2db_nameVARCHAR(32)Database name
3tablesINTNumber of tables in this vgroup. Note that tables is a TDengine keyword and needs to be escaped with `.
4statusVARCHAR(10)Status of this vgroup
5v1_dnodeINTID of the dnode where the first member is located
6v1_statusVARCHAR(10)Status of the first member
7v2_dnodeINTID of the dnode where the second member is located
8v2_statusVARCHAR(10)Status of the second member
9v3_dnodeINTID of the dnode where the third member is located
10v3_statusVARCHAR(10)Status of the third member
11nfilesINTNumber of data/metadata files in this vgroup
12file_sizeINTSize of data/metadata files in this vgroup
13tsmaTINYINTIndicates whether this vgroup is specifically for Time-range-wise SMA, 1: yes, 0: no

INS_CONFIGS

System configuration parameters.

#Column NameData TypeDescription
1nameVARCHAR(32)Configuration item name
2valueVARCHAR(64)Value of the configuration item. Note that value is a TDengine keyword and needs to be escaped with `.

INS_DNODE_VARIABLES

Configuration parameters for each dnode in the system. Users with SYSINFO set to 0 cannot view this table.

#Column NameData TypeDescription
1dnode_idINTID of the dnode
2nameVARCHAR(32)Configuration item name
3valueVARCHAR(64)Value of the configuration item. Note that value is a TDengine keyword and needs to be escaped with `.

INS_TOPICS

#Column NameData TypeDescription
1topic_nameVARCHAR(192)Topic name
2db_nameVARCHAR(64)Database related to the topic
3create_timeTIMESTAMPCreation time of the topic
4sqlVARCHAR(1024)SQL statement used to create this topic

INS_SUBSCRIPTIONS

#Column NameData TypeDescription
1topic_nameVARCHAR(204)Subscribed topic
2consumer_groupVARCHAR(193)Subscriber's consumer group
3vgroup_idINTvgroup id assigned to the consumer
4consumer_idBIGINTUnique id of the consumer
5userVARCHAR(24)Username of the consumer
6fqdnVARCHAR(128)FQDN of the machine where the consumer is located
7offsetVARCHAR(64)Consumer's consumption progress
8rowsBIGINTNumber of data records consumed

INS_STREAMS

#Column NameData TypeDescription
1stream_nameVARCHAR(64)Stream calculation name
2create_timeTIMESTAMPCreation time
3sqlVARCHAR(1024)SQL statement provided when creating the stream calculation
4statusVARCHAR(20)Current status of the stream
5source_dbVARCHAR(64)Source database
6target_dbVARCHAR(64)Target database
7target_tableVARCHAR(192)Target table where the stream calculation writes results
8watermarkBIGINTWatermark, see SQL manual for stream calculations. Note that watermark is a TDengine keyword and needs to be escaped with `.
9triggerINTPush result computation mode, see SQL manual for stream calculations. Note that trigger is a TDengine keyword and needs to be escaped with `.

INS_USER_PRIVILEGES

Note: Users with SYSINFO set to 0 cannot view this table.

#Column NameData TypeDescription
1user_nameVARCHAR(24)Username
2privilegeVARCHAR(10)Permission description
3db_nameVARCHAR(65)Database name
4table_nameVARCHAR(193)Table name
5conditionVARCHAR(49152)Subtable permission filter condition