22-meta.md 14.8 KB
Newer Older
1
---
2 3
sidebar_label: Metadata
title: Information_Schema Database
4 5
---

6
TDengine includes a built-in database named `INFORMATION_SCHEMA` to provide access to database metadata, system information, and status information. This information includes database names, table names, and currently running SQL statements. All information related to TDengine maintenance is stored in this database. It contains several read-only tables. These tables are more accurately described as views, and they do not correspond to specific files. You can query these tables but cannot write data to them. The INFORMATION_SCHEMA database is intended to provide a unified method for SHOW commands to access data. However, using SELECT ... FROM INFORMATION_SCHEMA.tablename offers several advantages over SHOW commands:
7

8 9 10 11 12
1. You can use a USE statement to specify the INFORMATION_SCHEMA database as the current database.
2. You can use the familiar SELECT syntax to access information, provided that you know the table and column names.
3. You can filter and order the query results. More generally, you can use any SELECT syntax that TDengine supports to query the INFORMATION_SCHEMA database.
4. Future versions of TDengine can add new columns to INFORMATION_SCHEMA tables without affecting existing business systems.
5. It is easier for users coming from other database management systems. For example, Oracle users can query data dictionary tables.
13

14
Note: SHOW statements are still supported for the convenience of existing users.
15

16
This document introduces the tables of INFORMATION_SCHEMA and their structure.
17 18 19

## INS_DNODES

20
Provides information about dnodes. Similar to SHOW DNODES.
21

22
| #   |    **Column**    | **Data Type** | **Description**                  |
23
| --- | :------------: | ------------ | ------------------------- |
24 25 26 27 28 29 30
| 1   |     vnodes     | SMALLINT     | Current number of vnodes on the dnode |
| 2   |     vnodes     | SMALLINT     | Maximum number of vnodes on the dnode |
| 3   |     status     | BINARY(10)   | Current status                  |
| 4   |      note      | BINARY(256)  | Reason for going offline or other information            |
| 5   |       id       | SMALLINT     | Dnode ID                  |
| 6   |    endpoint    | BINARY(134)  | Dnode endpoint              |
| 7   |     create     | TIMESTAMP    | Creation time                  |
31 32 33

## INS_MNODES

34
Provides information about mnodes. Similar to SHOW MNODES.
35

36
| #   |    **Column**    | **Data Type** | **Description**                  |
37
| --- | :---------: | ------------ | ------------------ |
38 39 40 41 42
| 1   |       id       | SMALLINT     | Mnode ID                  |
| 2   |    endpoint    | BINARY(134)  | Mnode endpoint              |
| 3   |    role     | BINARY(10)   | Current role           |
| 4   |  role_time  | TIMESTAMP    | Time at which the current role was assumed |
| 5   | create_time | TIMESTAMP    | Creation time           |
43 44 45

## INS_MODULES

46
Provides information about modules. Similar to SHOW MODULES.
47

48
| #   |    **Column**    | **Data Type** | **Description**                  |
49
| --- | :------: | ------------ | ---------- |
50 51 52
| 1   |       id       | SMALLINT     | Module ID                  |
| 2   |    endpoint    | BINARY(134)  | Module endpoint              |
| 3   |  module  | BINARY(10)   | Module status   |
53 54 55

## INS_QNODES

56
Provides information about qnodes. Similar to SHOW QNODES.
57

58
| #   |    **Column**    | **Data Type** | **Description**                  |
59
| --- | :---------: | ------------ | ------------ |
60 61 62
| 1   |       id       | SMALLINT     | Qnode ID                  |
| 2   |    endpoint    | BINARY(134)  | Qnode endpoint              |
| 3   | create_time | TIMESTAMP    | Creation time           |
63 64 65

## INS_CLUSTER

66
Provides information about the cluster.
67

68
| #   |    **Column**    | **Data Type** | **Description**                  |
69
| --- | :---------: | ------------ | ---------- |
70 71 72
| 1   |     id      | BIGINT       | Cluster ID |
| 2   |    name     | BINARY(134)  | Cluster name   |
| 3   | create_time | TIMESTAMP    | Creation time           |
73 74 75

## INS_DATABASES

76
Provides information about user-created databases. Similar to SHOW DATABASES.
77

78
| #   |    **Column**    | **Data Type** | **Description**                  |
79
| --- | :------------------: | ---------------- | ------------------------------------------------ |
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
| 1| name| BINARY(32)| Database name |
| 2   | create_time | TIMESTAMP    | Creation time           |
| 3   |       ntables        | INT              | Number of standard tables and subtables (not including supertables) |
| 4   |       vgroups        | INT              | Number of vgroups                           |
| 6   |       replica        | INT              | Number of replicas                                           |
| 7   |        quorum        | BINARY(3)        | Strong consistency                                         |
| 8   |       duration       | INT              | Duration for storage of single files                         |
| 9   |         keep         | INT              | Data retention period                                     |
| 10  |        buffer        | INT              | Write cache size per vnode, in MB           |
| 11  |       pagesize       | INT              | Page size for vnode metadata storage engine, in KB   |
| 12  |        pages         | INT              | Number of pages per vnode metadata storage engine            |
| 13  |       minrows        | INT              | Maximum number of records per file block                           |
| 14  |       maxrows        | INT              | Minimum number of records per file block                           |
| 15  |         comp         | INT              | Compression method                                     |
| 16  |      precision       | BINARY(2)        | Time precision                                      |
| 17  |        status        | BINARY(10)       | Current database status                                       |
| 18  |      retention       | BINARY (60)      | Aggregation interval and retention period                         |
| 19  |    single_stable     | BOOL             | Whether the database can contain multiple supertables           |
| 20  |      cachemodel      | BINARY(60)       | Caching method for the newest data               |
| 21  |      cachesize       | INT              | Memory per vnode used for caching the newest data  |
| 22  |      wal_level       | INT              | WAL level                                     |
| 23  |   wal_fsync_period   | INT              | Interval at which WAL is written to disk  |
| 24  | wal_retention_period | INT              | WAL retention period                                   |
| 25  |  wal_retention_size  | INT              | Maximum WAL size                                   |
| 26  |   wal_roll_period    | INT              | WAL rotation period                                 |
| 27  |   wal_segment_size   | WAL file size |
106 107 108

## INS_FUNCTIONS

109
Provides information about user-defined functions.
110

111
| #   |    **Column**    | **Data Type** | **Description**                  |
112
| --- | :---------: | ------------ | -------------- |
113 114 115 116 117 118 119
| 1   |    name     | BINARY(64)   | Function name         |
| 2   |   comment   | BINARY(255)  | Function description       |
| 3   |  aggregate  | INT          | Whether the UDF is an aggregate function |
| 4   | output_type | BINARY(31)   | Output data type       |
| 5   | create_time | TIMESTAMP    | Creation time       |
| 6   |  code_len   | INT          | Length of the source code       |
| 7   |   bufsize   | INT          | Buffer size    |
120 121 122

## INS_INDEXES

123
Provides information about user-created indices. Similar to SHOW INDEX.
124

125
| #   |    **Column**    | **Data Type** | **Description**                  |
126
| --- | :--------------: | ------------ | ---------------------------------------------------------------------------------- |
127 128 129 130 131 132
| 1   |     db_name      | BINARY(32)   | Database containing the table with the specified index                                                       |
| 2   |     table_name      | BINARY(192)   | Table containing the specified index                                                       |
| 3   |    index_name    | BINARY(192)  | Index name                                                                             |
| 4   |     db_name      | BINARY(64)   | Index column                                                       |
| 5   |    index_type    | BINARY(10)   | SMA or FULLTEXT index                                                             |
| 6   | index_extensions | BINARY(256)  | Other information For SMA indices, this shows a list of functions. For FULLTEXT indices, this is null. |
133 134 135

## INS_STABLES

136
Provides information about supertables.
137

138
| #   |    **Column**    | **Data Type** | **Description**                  |
139
| --- | :-----------: | ------------ | ------------------------ |
140 141 142 143 144 145 146 147 148 149
| 1   |  stable_name  | BINARY(192)  | Supertable name               |
| 2   |    db_name    | BINARY(64)   | All databases in the supertable |
| 3   |  create_time  | TIMESTAMP    | Creation time                 |
| 4   |    columns    | INT          | Number of columns                   |
| 5   |     tags      | INT          | Number of tags                |
| 6   |  last_update  | TIMESTAMP    | Last updated time             |
| 7   | table_comment | BINARY(1024) | Table description                   |
| 8   |   watermark   | BINARY(64)   | Window closing time           |
| 9   |   max_delay   | BINARY(64)   | Maximum delay for pushing stream processing results  |
| 10  |    rollup     | BINARY(128)  | Rollup aggregate function          |
150 151 152

## INS_TABLES

153
Provides information about standard tables and subtables.
154

155
| #   |    **Column**    | **Data Type** | **Description**                  |
156
| --- | :-----------: | ------------ | ---------------- |
157 158 159 160 161 162 163 164 165 166
| 1   |  table_name   | BINARY(192)  | Table name             |
| 2   |    db_name    | BINARY(64)   | Database name         |
| 3   |  create_time  | TIMESTAMP    | Creation time         |
| 4   |    columns    | INT          | Number of columns           |
| 5   |  stable_name  | BINARY(192)  | Supertable name |
| 6   |      uid      | BIGINT       | Table ID            |
| 7   |   vgroup_id   | INT          | Vgroup ID        |
| 8   |      ttl      | INT          | Table time-to-live    |
| 9   | table_comment | BINARY(1024) | Table description           |
| 10  |     type      | BINARY(20)   | Table type           |
167 168 169

## INS_TAGS

170
| #   |    **Column**    | **Data Type** | **Description**                  |
171
| --- | :---------: | ------------- | ---------------------- |
172 173 174 175 176 177
| 1   | table_name  | BINARY(192)   | Table name                   |
| 2   |   db_name   | BINARY(64)    | Database name |
| 3   | stable_name | BINARY(192)   | Supertable name       |
| 4   |  tag_name   | BINARY(64)    | Tag name             |
| 5   |  tag_type   | BINARY(64)    | Tag type             |
| 6   |  tag_value  | BINARY(16384) | Tag value               |
178 179 180

## INS_USERS

181
Provides information about TDengine users.
182

183
| #   |    **Column**    | **Data Type** | **Description**                  |
184
| --- | :---------: | ------------ | -------- |
185 186 187
| 1   |  user_name  | BINARY(23)   | User name   |
| 2   |  privilege  | BINARY(256)  | User permissions     |
| 3   | create_time | TIMESTAMP    | Creation time |
188 189 190

## INS_GRANTS

191
Provides information about TDengine Enterprise Edition permissions.
192

193
| #   |    **Column**    | **Data Type** | **Description**                  |
194
| --- | :---------: | ------------ | -------------------------------------------------- |
195 196 197 198 199 200 201 202 203 204 205 206 207 208
| 1   |   version   | BINARY(9)    | Whether the deployment is a licensed or trial version |
| 2   |  cpu_cores  | BINARY(9)    | CPU cores included in license                           |
| 3   |   dnodes    | BINARY(10)   | Dnodes included in license                         |
| 4   |   streams   | BINARY(10)   | Streams included in license                                   |
| 5   |    users    | BINARY(10)   | Users included in license                                 |
| 6   |   streams   | BINARY(10)   | Accounts included in license                                   |
| 7   |   storage   | BINARY(21)   | Storage space included in license                             |
| 8   | connections | BINARY(21)   | Client connections included in license                           |
| 9   |  databases  | BINARY(11)   | Databases included in license                               |
| 10  |    speed    | BINARY(9)    | Write speed specified in license (data points per second)                       |
| 11  |  querytime  | BINARY(9)    | Total query time specified in license                               |
| 12  | timeseries  | BINARY(21)   | Number of metrics included in license                                 |
| 13  |   expired   | BINARY(5)    | Whether the license has expired                |
| 14  | expire_time | BINARY(19)   | When the trial period expires                                     |
209 210 211

## INS_VGROUPS

212
Provides information about vgroups.
213

214
| #   |    **Column**    | **Data Type** | **Description**                  |
215
| --- | :-------: | ------------ | ------------------------------------------------------ |
216 217 218 219 220 221 222 223 224 225 226 227 228
| 1   | vgroup_id | INT          | Vgroup ID                                              |
| 2   |  db_name  | BINARY(32)   | Database name                                               |
| 3   |  tables   | INT          | Tables in vgroup                                  |
| 4   |  status   | BINARY(10)   | Vgroup status                                       |
| 5   | v1_dnode  | INT          | Dnode ID of first vgroup member                           |
| 6   | v1_status | BINARY(10)   | Status of first vgroup member                                       |
| 7   | v2_dnode  | INT          | Dnode ID of second vgroup member                           |
| 8   | v2_status | BINARY(10)   | Status of second vgroup member                                       |
| 9   | v3_dnode  | INT          | Dnode ID of third vgroup member                          |
| 10  | v3_status | BINARY(10)   | Status of third vgroup member                                       |
| 11  |  nfiles   | INT          | Number of data and metadata files in the vgroup                      |
| 12  | file_size | INT          | Size of the data and metadata files in the vgroup                      |
| 13  |   tsma    | TINYINT      | Whether time-range-wise SMA is enabled. 1 means enabled; 0 means disabled. |
229 230 231

## INS_CONFIGS

232
Provides system configuration information.
233

234
| #   |    **Column**    | **Data Type** | **Description**                  |
235
| --- | :------: | ------------ | ------------ |
236 237
| 1   |    name     | BINARY(32)  | Parameter   |
| 2   |  value   | BINARY(64)   | Value |
238 239 240

## INS_DNODE_VARIABLES

241
Provides dnode configuration information.
242

243
| #   |    **Column**    | **Data Type** | **Description**                  |
244
| --- | :------: | ------------ | ------------ |
245 246 247
| 1   | dnode_id | INT          | Dnode ID |
| 2   |   name   | BINARY(32)   | Parameter   |
| 3   |  value   | BINARY(64)   | Value |