The physical entities that form TDengine clusters are known as data nodes (dnodes). Each dnode is a process running on the operating system of the physical machine. Dnodes can contain virtual nodes (vnodes), which store time-series data. Virtual nodes are formed into vgroups, which have 1 or 3 vnodes depending on the replica setting. If you want to enable replication on your cluster, it must contain at least three nodes. Dnodes can also contain management nodes (mnodes). Each cluster has up to three mnodes. Finally, dnodes can contain query nodes (qnodes), which compute time-series data, thus separating compute from storage. A single dnode can contain a vnode, qnode, and mnode.
Enter the dnode_endpoint in hostname:port format. You can also specify the hostname and port as separate parameters.
Create the dnode before starting the corresponding dnode process. The dnode can then join the cluster based on the value of the firstEp parameter. Each dnode is assigned an ID after it joins a cluster.
## View Dnodes
```sql
SHOWDNODES;
```
The preceding SQL command shows all dnodes in the cluster with the ID, endpoint, and status.
## Delete a DNODE
```sql
DROPDNODE{dnode_id|dnode_endpoint}
```
You can delete a dnode by its ID or by its endpoint. Note that deleting a dnode does not stop its process. You must stop the process after the dnode is deleted.
## Modify Dnode Configuration
```sql
ALTERDNODEdnode_iddnode_option
ALTERALLDNODESdnode_option
dnode_option:{
'resetLog'
|'balance'value
|'monitor'value
|'debugFlag'value
|'monDebugFlag'value
|'vDebugFlag'value
|'mDebugFlag'value
|'cDebugFlag'value
|'httpDebugFlag'value
|'qDebugflag'value
|'sdbDebugFlag'value
|'uDebugFlag'value
|'tsdbDebugFlag'value
|'sDebugflag'value
|'rpcDebugFlag'value
|'dDebugFlag'value
|'mqttDebugFlag'value
|'wDebugFlag'value
|'tmrDebugFlag'value
|'cqDebugFlag'value
}
```
The parameters that you can modify through this statement are the same as those located in the dnode configuration file. Modifications that you make through this statement take effect immediately, while modifications to the configuration file take effect when the dnode restarts.
## Add an Mnode
```sql
CREATEMNODEONDNODEdnode_id
```
TDengine automatically creates an mnode on the firstEp node. You can use this statement to create more mnodes for higher system availability. A cluster can have a maximum of three mnodes. Each dnode can contain only one mnode.
## View Mnodes
```sql
SHOWMNODES;
```
This statement shows all mnodes in the cluster with the ID, dnode, and status.
## Delete an Mnode
```sql
DROPMNODEONDNODEdnode_id;
```
This statement deletes the mnode located on the specified dnode.
## Create a Qnode
```sql
CREATEQNODEONDNODEdnode_id;
```
TDengine does not automatically create qnodes on startup. You can create qnodes as necessary for compute/storage separation. Each dnode can contain only one qnode. If a qnode is created on a dnode whose supportVnodes parameter is not 0, a vnode and qnode may coexist on the dnode. Each dnode can have a maximum of one vnode, one qnode, and one mnode. However, you can configure your cluster so that vnodes, qnodes, and mnodes are located on separate dnodes. If you set supportVnodes to 0 for a dnode, you can then decide whether to deploy an mnode or a qnode on it. In this way you can physically separate virtual node types.
## View Qnodes
```sql
SHOWQNODES;
```
This statement shows all qnodes in the cluster with the ID and dnode.
## Delete a Qnode
```sql
DROPQNODEONDNODEdnode_id;
```
This statement deletes the mnode located on the specified dnode. This does not affect the status of the dnode.
## Modify Client Configuration
The client configuration can also be modified in a similar way to other cluster components.
```sql
ALTERLOCALlocal_option
local_option:{
'resetLog'
|'rpcDebugFlag'value
|'tmrDebugFlag'value
|'cDebugFlag'value
|'uDebugFlag'value
|'debugFlag'value
}
```
The parameters that you can modify through this statement are the same as those located in the client configuration file. Modifications that you make through this statement take effect immediately, while modifications to the configuration file take effect when the client restarts.
## View Client Configuration
```sql
SHOWLOCALVARIABLES;
```
## Combine Vgroups
```sql
MERGEVGROUPvgroup_no1vgroup_no2;
```
If load and data are not properly balanced among vgroups due to the data in different tim lines having different characteristics, you can combine or separate vgroups.
## Separate Vgroups
```sql
SPLITVGROUPvgroup_no;
```
This statement creates a new vgroup and migrates part of the data from the original vgroup to the new vgroup with consistent hashing. During this process, the original vgroup can continue to provide services normally.
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:
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.
Note: SHOW statements are still supported for the convenience of existing users.
This document introduces the tables of INFORMATION_SCHEMA and their structure.
## INS_DNODES
Provides information about dnodes. Similar to SHOW DNODES.
TDengine includes a built-in database named `PERFORMANCE_SCHEMA` to provide access to database performance statistics. This document introduces the tables of PERFORMANCE_SCHEMA and their structure.
## PERF_APP
Provides information about clients (such as applications) that connect to the cluster. Similar to SHOW APPS.
In addition to running SELECT statements on INFORMATION_SCHEMA, you can also use SHOW to obtain system metadata, information, and status.
## SHOW ACCOUNTS
```sql
SHOWACCOUNTS;
```
Shows information about tenants on the system.
Note: TDengine Enterprise Edition only.
## SHOW APPS
```sql
SHOWAPPS;
```
Shows all clients (such as applications) that connect to the cluster.
## SHOW BNODES
```sql
SHOWBNODES;
```
Shows information about backup nodes (bnodes) in the system.
## SHOW CLUSTER
```sql
SHOWCLUSTER;
```
Shows information about the current cluster.
## SHOW CONNECTIONS
```sql
SHOWCONNECTIONS;
```
Shows information about connections to the system.
## SHOW CONSUMERS
```sql
SHOWCONSUMERS;
```
Shows information about all active consumers in the system.
## SHOW CREATE DATABASE
```sql
SHOWCREATEDATABASEdb_name;
```
Shows the SQL statement used to create the specified database.
## SHOW CREATE STABLE
```sql
SHOWCREATESTABLE[db_name.]stb_name;
```
Shows the SQL statement used to create the specified supertable.
## SHOW CREATE TABLE
```sql
SHOWCREATETABLE[db_name.]tb_name
```
Shows the SQL statement used to create the specified table. This statement can be used on supertables, standard tables, and subtables.
## SHOW DATABASES
```sql
SHOWDATABASES;
```
Shows all user-created databases.
## SHOW DNODES
```sql
SHOWDNODES;
```
Shows all dnodes in the system.
## SHOW FUNCTIONS
```sql
SHOWFUNCTIONS;
```
Shows all user-defined functions in the system.
## SHOW LICENSE
```sql
SHOWLICENSE;
SHOWGRANTS;
```
Shows information about the TDengine Enterprise Edition license.
Note: TDengine Enterprise Edition only.
## SHOW INDEXES
```sql
SHOWINDEXESFROMtbl_name[FROMdb_name];
```
Shows indices that have been created.
## SHOW LOCAL VARIABLES
```sql
SHOWLOCALVARIABLES;
```
Shows the working configuration of the client.
## SHOW MNODES
```sql
SHOWMNODES;
```
Shows information about mnodes in the system.
## SHOW MODULES
```sql
SHOWMODULES;
```
Shows information about modules installed in the system.
## SHOW QNODES
```sql
SHOWQNODES;
```
Shows information about qnodes in the system.
## SHOW SCORES
```sql
SHOWSCORES;
```
Shows information about the storage space allowed by the license.
Note: TDengine Enterprise Edition only.
## SHOW SNODES
```sql
SHOWSNODES;
```
Shows information about stream processing nodes (snodes) in the system.
## SHOW STABLES
```sql
SHOW[db_name.]STABLES[LIKE'pattern'];
```
Shows all supertables in the current database. You can use LIKE for fuzzy matching.
## SHOW STREAMS
```sql
SHOWSTREAMS;
```
Shows information about streams in the system.
## SHOW SUBSCRIPTIONS
```sql
SHOWSUBSCRIPTIONS;
```
Shows all subscriptions in the current database.
## SHOW TABLES
```sql
SHOW[db_name.]TABLES[LIKE'pattern'];
```
Shows all standard tables and subtables in the current database. You can use LIKE for fuzzy matching.
## SHOW TABLE DISTRIBUTED
```sql
SHOWTABLEDISTRIBUTEDtable_name;
```
Shows how table data is distributed.
## SHOW TAGS
```sql
SHOWTAGSFROMchild_table_name[FROMdb_name];
```
Shows all tag information in a subtable.
## SHOW TOPICS
```sql
SHOWTOPICS;
```
Shows all topics in the current database.
## SHOW TRANSACTIONS
```sql
SHOWTRANSACTIONS;
```
Shows all running transactions in the system.
## SHOW USERS
```sql
SHOWUSERS;
```
Shows information about users on the system. This includes user-created users and system-defined users.
## SHOW VARIABLES
```sql
SHOWVARIABLES;
SHOWDNODEdnode_idVARIABLES;
```
Shows the working configuration of the parameters that must be the same on each node. You can also specify a dnode to show the working configuration for that node.
## SHOW VGROUPS
```sql
SHOW[db_name.]VGROUPS;
```
Shows information about all vgroups in the system or about the vgroups for a specified database.
## SHOW VNODES
```sql
SHOWVNODES[dnode_name];
```
Shows information about all vnodes in the system or about the vnodes for a specified dnode.
This document describes how to manage permissions in TDengine.
## Create a User
```sql
CREATEUSERuse_namePASS'password';
```
This statement creates a user account.
The maximum length of use_name is 23 bytes.
The maximum length of password is 128 bytes. The password can include leters, digits, and special characters excluding single quotation marks, double quotation marks, backticks, backslashes, and spaces. The password cannot be empty.
## Delete a User
```sql
DROPUSERuser_name;
```
## Modify User Information
```sql
ALTERUSERuser_namealter_user_clause
alter_user_clause:{
PASS'literal'
|ENABLEvalue
|SYSINFOvalue
}
```
- PASS: Modify the user password.
- ENABLE: Specify whether the user is enabled or disabled. 1 indicates enabled and 0 indicates disabled.
- SYSINFO: Specify whether the user can query system information. 1 indicates that the user can query system information and 0 indicates that the user cannot query system information.
## Grant Permissions
```sql
GRANTprivilegesONpriv_levelTOuser_name
privileges:{
ALL
|priv_type[,priv_type]...
}
priv_type:{
READ
|WRITE
}
priv_level:{
dbname.*
|*.*
}
```
Grant permissions to a user.
Permissions are granted on the database level. You can grant read or write permissions.
TDengine has superusers and standard users. The default superuser name is root. This account has all permissions. You can use the superuser account to create standard users. With no permissions, standard users can create databases and have permissions on the databases that they create. These include deleting, modifying, querying, and writing to their own databases. Superusers can grant users permission to read and write other databases. However, standard users cannot delete or modify databases created by other users.
For non-database objects such as users, dnodes, and user-defined functions, standard users have read permissions only, generally by means of the SHOW statement. Standard users cannot create or modify these objects.
In a complex environment, connections and query tasks may encounter errors or fail to return in a reasonable time. If this occurs, you can terminate the connection or task.
## Terminate a Connection
```sql
KILLCONNECTIONconn_id;
```
You can use the SHOW CONNECTIONS statement to find the conn_id.
## Terminate a Query
```sql
SHOWQUERYquery_id;
```
You can use the SHOW QUERIES statement to find the query_id.
## Terminate a Transaction
```sql
KILLTRANSACTIONtrans_id
```
You can use the SHOW TRANSACTIONS statement to find the trans_id.
## Reset Client Cache
```sql
RESETQUERYCACHE;
```
If metadata becomes desynchronized among multiple clients, you can use this command to clear the client-side cache. Clients then obtain the latest metadata from the server.
| 3 | _ROWTS pseudocolumn | Added | Indicates the primary key. Alias of _C0.
| 4 | INFORMATION_SCHEMA | Added | Database for system metadata containing all schema definitions
| 5 | PERFORMANCE_SCHEMA | Added | Database for system performance information.
| 6 | Connection queries | Deprecated | Connection queries are no longer supported. The syntax and interfaces are deprecated.
| 7 | Mixed operations | Enhanced | Mixing scalar and vector operations in queries has been enhanced and is supported in all SELECT clauses.
| 8 | Tag operations | Added | Tag columns can be used in queries and clauses like data columns.
| 9 | Timeline clauses and time functions in supertables | Enhanced | When PARTITION BY is not used, data in supertables is merged into a single timeline.
## SQL Syntax
The following data types can be used in the schema for standard tables.
| 1 | ALTER ACCOUNT | Deprecated| This Enterprise Edition-only statement has been removed. It returns the error "This statement is no longer supported."
| 2 | ALTER ALL DNODES | Added | Modifies the configuration of all dnodes.
| 3 | ALTER DATABASE | Modified | Deprecated<ul><li>QUORUM: Specified the required number of confirmations. STRICT is now used to specify strong or weak consistency. The STRICT parameter cannot be modified. </li><li>BLOCKS: Specified the memory blocks used by each vnode. BUFFER is now used to specify the size of the write cache pool for each vnode. </li><li>UPDATE: Specified whether update operations were supported. All databases now support updating data in certain columns. </li><li>CACHELAST: Specified how to cache the newest row of data. CACHEMODEL now replaces CACHELAST. </li><li>COMP: Cannot be modified. <br/>Added</li><li>CACHEMODEL: Specifies whether to cache the latest subtable data. </li><li>CACHESIZE: Specifies the size of the cache for the newest subtable data. </li><li>WAL_FSYNC_PERIOD: Replaces the FSYNC parameter. </li><li>WAL_LEVEL: Replaces the WAL parameter. <br/>Modified</li><li>REPLICA: Cannot be modified. </li><li>KEEP: Now supports units. </li></ul>
| 4 | ALTER STABLE | Modified | Deprecated<ul><li>CHANGE TAG: Modified the name of a tag. Replaced by RENAME TAG. <br/>Added</li><li>RENAME TAG: Replaces CHANGE TAG. </li><li>COMMENT: Specifies comments for a supertable. </li></ul>
| 5 | ALTER TABLE | Modified | Deprecated<ul><li>CHANGE TAG: Modified the name of a tag. Replaced by RENAME TAG. <br/>Added</li><li>RENAME TAG: Replaces CHANGE TAG. </li><li>COMMENT: Specifies comments for a standard table. </li><li>TTL: Specifies the time-to-live for a standard table. </li></ul>
| 6 | ALTER USER | Modified | Deprecated<ul><li>PRIVILEGE: Specified user permissions. Replaced by GRANT and REVOKE. <br/>Added</li><li>ENABLE: Enables or disables a user. </li><li>SYSINFO: Specifies whether a user can query system information. </li></ul>
| 7 | COMPACT VNODES | Not supported | Compacted the data on a vnode. Not supported.
| 8 | CREATE ACCOUNT | Deprecated| This Enterprise Edition-only statement has been removed. It returns the error "This statement is no longer supported."
| 9 | CREATE DATABASE | Modified | Deprecated<ul><li>BLOCKS: Specified the number of blocks for each vnode. BUFFER is now used to specify the size of the write cache pool for each vnode. </li><li>CACHE: Specified the size of the memory blocks used by each vnode. BUFFER is now used to specify the size of the write cache pool for each vnode. </li><li>CACHELAST: Specified how to cache the newest row of data. CACHEMODEL now replaces CACHELAST. </li><li>DAYS: The length of time to store in a single file. Replaced by DURATION. </li><li>FSYNC: Specified the fsync interval when WAL was set to 2. Replaced by WAL_FSYNC_PERIOD. </li><li>QUORUM: Specified the number of confirmations required. STRICT is now used to specify strong or weak consistency. </li><li>UPDATE: Specified whether update operations were supported. All databases now support updating data in certain columns. </li><li>WAL: Specified the WAL level. Replaced by WAL_LEVEL. <br/>Added</li><li>BUFFER: Specifies the size of the write cache pool for each vnode. </li><li>CACHEMODEL: Specifies whether to cache the latest subtable data. </li><li>CACHESIZE: Specifies the size of the cache for the newest subtable data. </li><li>DURATION: Replaces DAYS. Now supports units. </li><li>PAGES: Specifies the number of pages in the metadata storage engine cache on each vnode. </li><li>PAGESIZE: specifies the size (in KB) of each page in the metadata storage engine cache on each vnode. </li><li>RETENTIONS: Specifies the aggregation interval and retention period </li><li>STRICT: Specifies whether strong data consistency is enabled. </li><li>SINGLE_STABLE: Specifies whether a database can contain multiple supertables. </li><li>VGROUPS: Specifies the initial number of vgroups when a database is created. </li><li>WAL_FSYNC_PERIOD: Replaces the FSYNC parameter. </li><li>WAL_LEVEL: Replaces the WAL parameter. </li><li>WAL_RETENTION_PERIOD: specifies the time after which WAL files are deleted. This parameter is used for data subscription. </li><li>WAL_RETENTION_SIZE: specifies the size at which WAL files are deleted. This parameter is used for data subscription. </li><li>WAL_ROLL_PERIOD: Specifies the WAL rotation period. </li><li>WAL_SEGMENT_SIZE: specifies the maximum size of a WAL file. <br/>Modified</li><li>KEEP: Now supports units. </li></ul>
| 10 | CREATE DNODE | Modified | Now supports specifying hostname and port separately<ul><li>CREATE DNODE dnode_host_name PORT port_val</li></ul>
| 11 | CREATE INDEX | Added | Creates an SMA index.
| 12 | CREATE MNODE | Added | Creates an mnode.
| 13 | CREATE QNODE | Added | Creates a qnode.
| 14 | CREATE STABLE | Modified | New parameter added<li>COMMENT: Specifies comments for the supertable. </li>
| 15 | CREATE STREAM | Added | Creates a stream.
| 16 | CREATE TABLE | Modified | New parameters added<ul><li>COMMENT: Specifies comments for the table </li><li>WATERMARK: Specifies the window closing time. </li><li>MAX_DELAY: Specifies the maximum delay for pushing stream processing results. </li><li>ROLLUP: Specifies aggregate functions to roll up. Rolling up a function provides downsampled results based on multiple axes. </li><li>SMA: Provides user-defined precomputation of aggregates based on data blocks. </li><li>TTL: Specifies the time-to-live for a standard table. </li></ul>
| 17 | CREATE TOPIC | Added | Creates a topic.
| 18 | DROP ACCOUNT | Deprecated| This Enterprise Edition-only statement has been removed. It returns the error "This statement is no longer supported."
| 19 | DROP CONSUMER GROUP | Added | Deletes a consumer group.
| 29 | KILL STREAM | Deprecated | Terminated a continuous query. The continuous query feature has been replaced with the stream processing feature.
| 30 | MERGE VGROUP | Added | Merges vgroups.
| 31 | REVOKE | Added | Revokes permissions from a user.
| 32 | SELECT | Modified | <ul><li>SELECT does not use the implicit results column. Output columns must be specified in the SELECT clause. </li><li>DISTINCT support is enhanced. In previous versions, DISTINCT only worked on the tag column and could not be used with JOIN or GROUP BY. </li><li>JOIN support is enhanced. The following are now supported after JOIN: a WHERE clause with OR, operations on multiple tables, and GROUP BY on multiple tables. </li><li>Subqueries after FROM are enhanced. Levels of nesting are no longer restricted. Subqueries can be used with UNION ALL. Other syntax restrictions are eliminated. </li><li>All scalar functions can be used after WHERE. </li><li>GROUP BY is enhanced. You can group by any scalar expression or combination thereof. </li><li>SESSION can be used on supertables. When PARTITION BY is not used, data in supertables is merged into a single timeline. </li><li>STATE_WINDOW can be used on supertables. When PARTITION BY is not used, data in supertables is merged into a single timeline. </li><li>ORDER BY is enhanced. It is no longer required to use ORDER BY and GROUP BY together. There is no longer a restriction on the number of order expressions. NULLS FIRST and NULLS LAST syntax has been added. Any expression that conforms to the ORDER BY semantics can be used. </li><li>Added PARTITION BY syntax. PARTITION BY replaces GROUP BY tags. </li></ul>
| 33 | SHOW ACCOUNTS | Deprecated | This Enterprise Edition-only statement has been removed. It returns the error "This statement is no longer supported."
| 34 | SHOW APPS | Added | Shows all clients (such as applications) that connect to the cluster.
| 35 | SHOW CONSUMERS | Added | Shows information about all active consumers in the system.
| 36 | SHOW DATABASES | Modified | Only shows database names.
| 37 | SHOW FUNCTIONS | Modified | Only shows UDF names.
| 38 | SHOW LICENCE | Added | Alias of SHOW GRANTS.
| 39 | SHOW INDEXES | Added | Shows indices that have been created.
| 40 | SHOW LOCAL VARIABLES | Added | Shows the working configuration of the client.
| 41 | SHOW MODULES | Deprecated | Shows information about modules installed in the system.
| 42 | SHOW QNODES | Added | Shows information about qnodes in the system.
| 43 | SHOW STABLES | Modified | Only shows supertable names.
| 44 | SHOW STREAMS | Modified | This statement previously showed continuous queries. The continuous query feature has been replaced with the stream processing feature. This statement now shows streams that have been created.
| 45 | SHOW SUBSCRIPTIONS | Added | Shows all subscriptions in the current database.
| 46 | SHOW TABLES | Modified | Only shows table names.
| 47 | SHOW TABLE DISTRIBUTED | Added | Shows how table data is distributed. This replaces the `SELECT _block_dist() FROM { tb_name | stb_name }` command.
| 48 | SHOW TOPICS | Added | Shows all subscribed topics in the current database.
| 49 | SHOW TRANSACTIONS | Added | Shows all running transactions in the system.
| 50 | SHOW DNODE VARIABLES | Added | Shows the configuration of the specified dnode.
| 51 | SHOW VNODES | Not supported | Shows information about vnodes in the system. Not supported.
| 52 | SPLIT VGROUP | Added | Splits a vgroup into two vgroups.
| 53 | TRIM DATABASE | Added | Deletes data that has expired and orders the remaining data in accordance with the storage configuration.