Skip to main content

Syntax Changes in TDengine 3.0

Changes to SQL Basic Elements

#Element
Difference
Description
1VARCHARAddedAlias for the BINARY type.
2TIMESTAMP literalAddedSupports the syntax TIMESTAMP 'timestamp format'.
3_ROWTS pseudocolumnAddedRepresents the timestamp primary key. Alias for the _C0 pseudo column.
4_IROWTS pseudocolumnAddedUsed to return the timestamp column corresponding to the interpolation result of the interp function.
5INFORMATION_SCHEMAAddedSystem database containing various SCHEMA definitions.
6PERFORMANCE_SCHEMAAddedSystem database containing operational information.
7Continuous QueryDeprecatedContinuous queries are no longer supported. Various related syntax and interfaces are deprecated.
8Mixed OperationsEnhancedComprehensive enhancement of mixed operations (scalar and vector operations mixed) in queries, all clauses of SELECT fully support mixed operations complying with syntax semantics.
9Tag OperationsAddedIn queries, tag columns can participate in various operations like normal columns, used in various clauses.
10Timeline Clause and Time Functions for Supertable QueriesEnhancedWithout PARTITION BY, the data of the supertable will be merged into one timeline.
11GEOMETRYAddedGeometry type.

SQL Statement Changes

In TDengine, the following data types can be used in the data model of basic tables.

#Statement
Difference
Description
1ALTER ACCOUNTDeprecatedWas an enterprise feature in 2.x, no longer supported in 3.0. Syntax is temporarily retained, execution reports “This statement is no longer supported” error.
2ALTER ALL DNODESAddedModify parameters of all DNODEs.
3ALTER DATABASEAdjusted

Deprecated

  • QUORUM: The number of replica confirmations needed for writing. The default behavior in version 3.0 is strong consistency, and weak consistency is not supported.
  • 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. All databases in version 3.0 support partial column updates.
  • CACHELAST: Mode for caching the latest row of data. Replaced by CACHEMODEL in version 3.0.
  • COMP: Not supported for modification in version 3.0.

Added

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

Adjusted

  • KEEP: Version 3.0 added support for settings with units.
4ALTER STABLEAdjustedDeprecated
  • CHANGE tag: Change the name of the tag column. Replaced by RENAME tag in version 3.0.
    Added
  • RENAME tag: Replaces the original CHANGE tag clause.
  • COMMENT: Modify the comment of the supertable.
5ALTER TABLEAdjustedDeprecated
  • CHANGE tag: Change the name of the tag column. Replaced by RENAME tag in version 3.0.
    Added
  • RENAME tag: Replaces the original CHANGE tag clause.
  • COMMENT: Modify the comment of the table.
  • TTL: Modify the lifecycle of the table.
6ALTER USERAdjustedDeprecated
  • PRIVILEGE: Modify user permissions. Version 3.0 uses GRANT and REVOKE to grant and revoke permissions.
    Added
  • ENABLE: Enable or disable this user.
  • SYSINFO: Modify whether the user can view system information.
7COMPACT VNODESNot supportedCompact data of specified VNODE. Not supported in version 3.0.0.
8CREATE ACCOUNTDeprecatedWas an enterprise feature in 2.x, no longer supported in 3.0. Syntax is temporarily retained, execution reports “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 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. Replaced by CACHEMODEL in version 3.0.
  • DAYS: The time span for storing data in data files. Replaced by DURATION in version 3.0.
  • FSYNC: When WAL is set to 2, the period for performing fsync. Replaced by WAL_FSYNC_PERIOD in version 3.0.
  • QUORUM: The number of replica confirmations needed for writing. Version 3.0 uses STRICT to specify strong or weak consistency.
  • UPDATE: Support mode for update operations. All databases in version 3.0 support partial column updates.
  • WAL: WAL level. Replaced by WAL_LEVEL in version 3.0.

Added

  • BUFFER: The size of the memory pool for a VNODE write.
  • CACHEMODEL: Indicates whether to cache recent data of subtables in memory.
  • CACHESIZE: Indicates the memory size for caching recent data of subtables.
  • DURATION: Replaces the original DAYS parameter. Added support for settings with units.
  • PAGES: The number of cache pages in the metadata storage engine of a VNODE.
  • PAGESIZE: The page size in the metadata storage engine of a VNODE.
  • RETENTIONS: Indicates the data aggregation period and retention duration.
  • STRICT: Indicates the consistency requirement 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: Extra retention strategy for wal files, used for data subscription.
  • WAL_RETENTION_SIZE: Extra retention strategy for wal files, used for data subscription.

Adjusted

  • KEEP: Version 3.0 added support for settings with units.
10CREATE DNODEAdjustedAdded syntax to specify hostname and port number separately
  • CREATE DNODE dnode_host_name PORT port_val
11CREATE INDEXAddedCreate SMA index.
12CREATE MNODEAddedCreate management node.
13CREATE QNODEAddedCreate query node.
14CREATE STABLEAdjustedAdded table parameter syntax
  • COMMENT: Table comment.
  • 15CREATE STREAMAddedCreate stream.
    16CREATE TABLEAdjustedAdded table parameter syntax
    • COMMENT: Table comment.
    • WATERMARK: Specifies the closing time of the window.
    • MAX_DELAY: Used to control the maximum delay in pushing calculation results.
    • ROLLUP: Specifies the aggregation function, providing multi-level downsampling aggregation results.
    • SMA: Provides custom pre-computation based on data blocks.
    • TTL: Parameter used to specify the lifecycle of the table.
    17CREATE TOPICAddedCreate subscription topic.
    18DROP ACCOUNTDeprecatedWas an enterprise feature in 2.x, no longer supported in 3.0. Syntax is temporarily retained, execution reports “This statement is no longer supported” error.
    19DROP CONSUMER GROUPAddedDelete consumer group.
    20DROP INDEXAddedDelete index.
    21DROP MNODEAddedCreate management node.
    22DROP QNODEAddedCreate query node.
    23DROP STREAMAddedDelete stream.
    24DROP TABLEAdjustedAdded batch delete syntax
    25DROP TOPICAddedDelete subscription topic.
    26EXPLAINAddedView the execution plan of a query statement.
    27GRANTAddedGrant user permissions.
    28KILL TRANSACTIONAddedTerminate the transaction of the management node.
    29KILL STREAMDeprecatedTerminate continuous query. Version 3.0 no longer supports continuous queries, replaced by more general stream computing.
    31REVOKEAddedRevoke user permissions.
    32SELECTAdjusted
    • SELECT closes implicit result columns, output columns must be specified by the SELECT clause.
    • DISTINCT functionality fully supported. Version 2.x only supported deduplication of tag columns and could not be mixed with JOIN, GROUP BY, etc.
    • JOIN functionality enhanced. Added support: OR conditions in WHERE conditions after JOIN; multi-table operations after JOIN; multi-table GROUP BY after JOIN.
    • Subquery functionality after FROM significantly enhanced. No limit on subquery nesting levels; supports mixed use of subqueries and UNION ALL; removes some other previous version syntax restrictions.
    • Any scalar expression can be used after WHERE.
    • GROUP BY functionality enhanced. Supports any scalar expression and their combinations for grouping.
    • SESSION can be used for supertables now. Without PARTITION BY, the data of the supertable will be merged into one timeline.
    • STATE_WINDOW can be used for supertables now. Without PARTITION BY, the data of the supertable will be merged into one timeline.
    • ORDER BY functionality significantly enhanced. No longer must be used with the GROUP BY clause; no longer has a limit on the number of sorting expressions; added support for NULLS FIRST/LAST syntax functionality; supports any expression complying with syntax semantics.
    • Added PARTITION BY syntax. Replaces the original GROUP BY tags.
    33SHOW ACCOUNTSDeprecatedWas an enterprise feature in 2.x, no longer supported in 3.0. Syntax is temporarily retained, execution reports “This statement is no longer supported” error.
    34SHOW APPSAddedDisplay information about applications (clients) accessing the cluster.
    35SHOW CONSUMERSAddedDisplay 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 LICENCEAddedEquivalent to the SHOW GRANTS command.
    39SHOW INDEXESAddedDisplay created indexes.
    40SHOW LOCAL VARIABLESAddedDisplay runtime values of the current client's configuration parameters.
    41SHOW MODULESDeprecatedDisplay information about components installed in the current system.
    42SHOW QNODESAddedDisplay information about QNODEs in the current system.
    43SHOW STABLESAdjustedVersion 3.0 only displays supertable names.
    44SHOW STREAMSAdjustedVersion 2.x this command displayed information about continuous queries created in the system. Version 3.0 has deprecated continuous queries, replaced by streams. This command displays created streams.
    45SHOW SUBSCRIPTIONSAddedDisplay all subscription relationships in the current database
    46SHOW TABLESAdjustedVersion 3.0 only displays table names.
    47SHOW TABLE DISTRIBUTEDAddedDisplay table data distribution information. Replaces the SELECT _block_dist() FROM { tb_name
    48SHOW TOPICSAddedDisplay all subscription topics in the current database.
    49SHOW TRANSACTIONSAddedDisplay information about transactions currently being executed in the system.
    50SHOW DNODE VARIABLESAddedDisplay configuration parameters of a specified DNODE.
    51SHOW VNODESNot supportedDisplay information about VNODEs in the current system. Not supported in version 3.0.0.
    52TRIM DATABASEAddedDelete expired data and reorganize data according to multi-level storage configuration.
    53REDISTRIBUTE VGROUPAddedAdjust the distribution of VNODEs in a VGROUP.
    54BALANCE VGROUPAddedAutomatically adjust the distribution of VNODEs in a VGROUP.

    SQL Function Changes

    #Function
    Differences
    Description
    1TWAEnhancedCan now be used directly on supertables. Without PARTITION BY, the data of the supertable will be merged into one timeline.
    2IRATEEnhancedCan now be used directly on supertables. Without PARTITION BY, the data of the supertable will be merged into one timeline.
    3LEASTSQUARESEnhancedCan now be used on supertables.
    4ELAPSEDEnhancedCan now be used directly on supertables. Without PARTITION BY, the data of the supertable will be merged into one timeline.
    5DIFFEnhancedCan now be used directly on supertables. Without PARTITION BY, the data of the supertable will be merged into one timeline.
    6DERIVATIVEEnhancedCan now be used directly on supertables. Without PARTITION BY, the data of the supertable will be merged into one timeline.
    7CSUMEnhancedCan now be used directly on supertables. Without PARTITION BY, the data of the supertable will be merged into one timeline.
    8MAVGEnhancedCan now be used directly on supertables. Without PARTITION BY, the data of the supertable will be merged into one timeline.
    9SAMPLEEnhancedCan now be used directly on supertables. Without PARTITION BY, the data of the supertable will be merged into one timeline.
    10STATECOUNTEnhancedCan now be used directly on supertables. Without PARTITION BY, the data of the supertable will be merged into one timeline.
    11STATEDURATIONEnhancedCan now be used directly on supertables. Without PARTITION BY, the data of the supertable will be merged into one timeline.
    12TIMETRUNCATEEnhancedAdded ignore_timezone parameter, optional use, default value is 1.

    SCHEMALESS Changes

    #Element
    Differences
    Description
    1Primary key ts changed to _tsChangedSchemaless automatically created column names start with _, different from 2.x.