Skip to main content

Syntax Changes in TDengine 3.0

Changes to SQL Basic Elements

#ElementDifferenceDescription
1VARCHARNewAlias for BINARY type.
2TIMESTAMP LiteralNewSupports TIMESTAMP 'timestamp format' syntax.
3_ROWTS Pseudo ColumnNewRepresents the timestamp primary key. Alias for _C0 pseudo column.
4_IROWTS Pseudo ColumnNewUsed to return the timestamp column corresponding to the interp function interpolation result.
5INFORMATION_SCHEMANewSystem database containing various SCHEMA definitions.
6PERFORMANCE_SCHEMANewSystem database containing runtime information.
7Continuous QueryDeprecatedContinuous queries are no longer supported. Related syntax and interfaces are deprecated.
8Mixed OperationsEnhancedMixed operations (scalar and vector operations) in queries are fully enhanced, with all subclauses of SELECT fully supporting syntax semantics of mixed operations.
9Tag OperationsNewIn queries, tag columns can participate in various operations like ordinary columns for various clauses.
10Timeline Clause and Time Functions for Supertable QueriesEnhancedWithout PARTITION BY, the data of supertables will be merged into one timeline.
11GEOMETRYNewGeometry type.

Changes to SQL Statements

In TDengine, the data model of basic tables can use the following data types.

#StatementDifferenceDescription
1ALTER ACCOUNTDeprecatedThis was a feature in the enterprise version of 2.x, not supported in 3.0. The syntax is temporarily retained, executing results in "This statement is no longer supported" error.
2ALTER ALL DNODESNewModify parameters for all DNODEs.
3ALTER DATABASEAdjusted

Deprecated

  • QUORUM: The number of replicas required for write confirmation. The default behavior in version 3.0 is strong consistency and does not support modification to weak consistency.
  • BLOCKS: The number of memory blocks used by VNODE. Version 3.0 uses BUFFER to represent the size of the VNODE write memory pool.
  • UPDATE: Support mode for update operations. Version 3.0 supports partial column updates for all databases.
  • CACHELAST: Mode for caching the latest row of data. Version 3.0 replaces it with CACHEMODEL.
  • COMP: Not supported for modification in version 3.0.

New

  • CACHEMODEL: Indicates whether to cache the most recent data of subtables in memory.
  • CACHESIZE: Indicates the memory size used to cache the most recent data of subtables.
  • WAL_FSYNC_PERIOD: Replaces the original FSYNC parameter.
  • WAL_LEVEL: Replaces the original WAL parameter.
  • WAL_RETENTION_PERIOD: New in version 3.0.4.0, additional retention strategy for wal files, used for data subscription.
  • WAL_RETENTION_SIZE: New in version 3.0.4.0, additional retention strategy for wal files, used for data subscription.

Adjusted

  • KEEP: Version 3.0 adds support for setting with units.
4ALTER STABLEAdjustedDeprecated
  • CHANGE TAG: Modify the name of a tag column. Version 3.0 uses RENAME TAG instead.
    New
  • RENAME TAG: Replaces the original CHANGE TAG clause.
  • COMMENT: Modifies the comment of the supertable.
5ALTER TABLEAdjustedDeprecated
  • CHANGE TAG: Modify the name of a tag column. Version 3.0 uses RENAME TAG instead.
    New
  • RENAME TAG: Replaces the original CHANGE TAG clause.
  • COMMENT: Modifies the table's comment.
  • TTL: Modifies the table's lifecycle.
6ALTER USERAdjustedDeprecated
  • PRIVILEGE: Modify user permissions. Version 3.0 uses GRANT and REVOKE to grant and revoke permissions.
    New
  • ENABLE: Enable or disable this user.
  • SYSINFO: Modify whether the user can view system information.
7COMPACT VNODESNot SupportedOrganize the data of the specified VNODE. Not supported in version 3.0.0.
8CREATE ACCOUNTDeprecatedThis was a feature in the enterprise version of 2.x, not supported in 3.0. The syntax is temporarily retained, executing results in "This statement is no longer supported" error.
9CREATE DATABASEAdjusted

Deprecated

  • BLOCKS: The number of memory blocks used by VNODE. Version 3.0 uses BUFFER to represent the size of the VNODE write memory pool.
  • CACHE: The size of the memory blocks used by VNODE. Version 3.0 uses BUFFER to represent the size of the VNODE write memory pool.
  • CACHELAST: Mode for caching the latest row of data. Version 3.0 replaces it with CACHEMODEL.
  • DAYS: The time span for data file storage. Version 3.0 replaces it with DURATION.
  • FSYNC: The period of executing fsync when WAL is set to 2. Version 3.0 replaces it with WAL_FSYNC_PERIOD.
  • QUORUM: The number of replicas required for write confirmation. Version 3.0 uses STRICT to specify strong or weak consistency.
  • UPDATE: Support mode for update operations. Version 3.0 supports partial column updates for all databases.
  • WAL: WAL level. Version 3.0 replaces it with WAL_LEVEL.

New

  • BUFFER: The size of a VNODE's write memory pool.
  • CACHEMODEL: Indicates whether to cache the most recent data of subtables in memory.
  • CACHESIZE: Indicates the memory size used to cache the most recent data of subtables.
  • DURATION: Replaces the original DAYS parameter. Adds support for setting with units.
  • PAGES: The number of cached pages in a VNODE's metadata storage engine.
  • PAGESIZE: The page size of the metadata storage engine in a VNODE.
  • RETENTIONS: Indicates the aggregation cycle and retention duration of the data.
  • STRICT: Indicates the consistency requirements for data synchronization.
  • SINGLE_STABLE: Indicates whether only one supertable can be created in this database.
  • VGROUPS: The initial number of VGROUPs in the database.
  • WAL_FSYNC_PERIOD: Replaces the original FSYNC parameter.
  • WAL_LEVEL: Replaces the original WAL parameter.
  • WAL_RETENTION_PERIOD: Additional retention strategy for wal files, used for data subscription.
  • WAL_RETENTION_SIZE: Additional retention strategy for wal files, used for data subscription.

Adjusted

  • KEEP: Version 3.0 adds support for setting with units.
10CREATE DNODEAdjustedNew syntax for specifying hostname and port separately
  • CREATE DNODE dnode_host_name PORT port_val
11CREATE INDEXNewCreate SMA index.
12CREATE MNODENewCreate management node.
13CREATE QNODENewCreate query node.
14CREATE STABLEAdjustedNew table parameter syntax
  • COMMENT: Table comment.
  • 15CREATE STREAMNewCreate stream.
    16CREATE TABLEAdjustedNew table parameter syntax
    • COMMENT: Table comment.
    • WATERMARK: Specify the closing time of the window.
    • MAX_DELAY: Control the maximum delay for pushing computation results.
    • ROLLUP: Specify aggregation functions, providing down-sampling aggregation results based on multiple levels.
    • SMA: Provide custom pre-calculation functions based on data blocks.
    • TTL: Parameter used to specify the lifecycle of the table.
    17CREATE TOPICNewCreate subscription topic.
    18DROP ACCOUNTDeprecatedThis was a feature in the enterprise version of 2.x, not supported in 3.0. The syntax is temporarily retained, executing results in "This statement is no longer supported" error.
    19DROP CONSUMER GROUPNewDelete consumer group.
    20DROP INDEXNewDelete index.
    21DROP MNODENewCreate management node.
    22DROP QNODENewCreate query node.
    23DROP STREAMNewDelete stream.
    24DROP TABLEAdjustedNew syntax for batch deletion.
    25DROP TOPICNewDelete subscription topic.
    26EXPLAINNewView the execution plan of a query statement.
    27GRANTNewGrant user permissions.
    28KILL TRANSACTIONNewTerminate the transaction management node.
    29KILL STREAMDeprecatedTerminate continuous queries. Continuous queries are no longer supported in version 3.0 and are replaced by a more generic stream computation.
    31REVOKENewRevoke user permissions.
    32SELECTAdjusted
    • SELECT closes implicit result columns; all output columns must be specified in the SELECT clause.
    • DISTINCT functionality is fully supported. Version 2.x only supported deduplication of tag columns and could not be mixed with JOIN, GROUP BY, etc.
    • JOIN functionality is enhanced. Added support for: WHERE conditions with OR after JOIN; multi-table operations after JOIN; multi-table GROUP BY after JOIN.
    • Subquery functionality after FROM is significantly enhanced. No restriction on the number of nested subqueries; supports mixing subqueries with UNION ALL; removes some syntax restrictions from previous versions.
    • Arbitrary scalar expressions can be used after WHERE.
    • GROUP BY functionality is enhanced. Supports grouping by any scalar expression and their combinations.
    • SESSION can now be used for supertables. Without PARTITION BY, the data of supertables will be merged into one timeline.
    • STATE_WINDOW can now be used for supertables. Without PARTITION BY, the data of supertables will be merged into one timeline.
    • ORDER BY functionality is greatly enhanced. No longer must be used together with the GROUP BY clause; no longer has a limit on the number of sorting expressions; adds support for NULLS FIRST/LAST syntax; supports any expression that meets the syntax semantics.
    • New PARTITION BY syntax replaces the original GROUP BY tags.
    33SHOW ACCOUNTSDeprecatedThis was a feature in the enterprise version of 2.x, not supported in 3.0. The syntax is temporarily retained, executing results in "This statement is no longer supported" error.
    34SHOW APPSNewDisplays information about applications (clients) accessing the cluster.
    35SHOW CONSUMERSNewDisplays information about all active consumers in the current database.
    36SHOW DATABASESAdjustedVersion 3.0 only displays database names.
    37SHOW FUNCTIONSAdjustedVersion 3.0 only displays custom function names.
    38SHOW LICENCENewEquivalent to the SHOW GRANTS command.
    39SHOW INDEXESNewDisplays the indexes that have been created.
    40SHOW LOCAL VARIABLESNewDisplays the runtime values of the current client configuration parameters.
    41SHOW MODULESDeprecatedDisplays information about the components installed in the current system.
    42SHOW QNODESNewDisplays information about QNODEs in the current system.
    43SHOW STABLESAdjustedVersion 3.0 only displays supertable names.
    44SHOW STREAMSAdjustedIn version 2.x, this command displayed information about the continuous queries created in the system. Continuous queries are deprecated in version 3.0, replaced by streams. This command displays the streams that have been created.
    45SHOW SUBSCRIPTIONSNewDisplays all subscription relationships in the current database.
    46SHOW TABLESAdjustedVersion 3.0 only displays table names.
    47SHOW TABLE DISTRIBUTEDNewDisplays the data distribution information of a table. Replaces the SELECT _block_dist() FROM { tb_name
    48SHOW TOPICSNewDisplays all subscription topics in the current database.
    49SHOW TRANSACTIONSNewDisplays information about transactions currently being executed in the system.
    50SHOW DNODE VARIABLESNewDisplays configuration parameters for the specified DNODE.
    51SHOW VNODESNot SupportedDisplays information about VNODES in the current system. Not supported in version 3.0.0.
    52TRIM DATABASENewDeletes expired data and organizes data based on multi-level storage configuration.
    53REDISTRIBUTE VGROUPNewAdjusts the distribution of VNODES in VGROUP.
    54BALANCE VGROUPNewAutomatically adjusts the distribution of VNODES in VGROUP.

    Changes to SQL Functions

    #FunctionDifferenceDescription
    1TWAEnhancedCan now be used directly with supertables. Without PARTITION BY, the data of supertables will be merged into one timeline.
    2IRATEEnhancedCan now be used directly with supertables. Without PARTITION BY, the data of supertables will be merged into one timeline.
    3LEASTSQUARESEnhancedCan be used with supertables.
    4ELAPSEDEnhancedCan now be used directly with supertables. Without PARTITION BY, the data of supertables will be merged into one timeline.
    5DIFFEnhancedCan now be used directly with supertables. Without PARTITION BY, the data of supertables will be merged into one timeline.
    6DERIVATIVEEnhancedCan now be used directly with supertables. Without PARTITION BY, the data of supertables will be merged into one timeline.
    7CSUMEnhancedCan now be used directly with supertables. Without PARTITION BY, the data of supertables will be merged into one timeline.
    8MAVGEnhancedCan now be used directly with supertables. Without PARTITION BY, the data of supertables will be merged into one timeline.
    9SAMPLEEnhancedCan now be used directly with supertables. Without PARTITION BY, the data of supertables will be merged into one timeline.
    10STATECOUNTEnhancedCan now be used directly with supertables. Without PARTITION BY, the data of supertables will be merged into one timeline.
    11STATEDURATIONEnhancedCan now be used directly with supertables. Without PARTITION BY, the data of supertables will be merged into one timeline.
    12TIMETRUNCATEEnhancedAdds ignore_timezone parameter, which is optional and defaults to 1.

    Changes to SCHEMALESS

    #ElementDifferenceDescription
    1Primary Key ts changed to _tsChangeAutomatically created column names in schemaless begin with an underscore, unlike 2.x.