TDengine SQL

    TDengine SQL is the major interface for users to write data into or query from TDengine. It uses standard SQL syntax and includes extensions and optimizations for time-series data and services. The maximum length of a TDengine SQL statement is 1 MB. Note that keyword abbreviations are not supported. For example, DELETE cannot be entered as DEL.

    Syntax Specifications used in this chapter:

    • Keywords are given in uppercase, although SQL is not case-sensitive.
    • means optional input, excluding [] itself.
    • … means the item prior to it can be repeated multiple times.

    To better demonstrate the syntax, usage and rules of TDengine SQL, hereinafter it’s assumed that there is a data set of data from electric meters. Each meter collects 3 data measurements: current, voltage, phase. The data model is shown below:

    The data set includes the data collected by 4 meters, the corresponding table name is d1001, d1002, d1003 and d1004 based on the data model of TDengine.

    📄️ Data TypesTDengine supports a variety of data types including timestamp, float, JSON and many others.

    📄️ TableCreate Table

    📄️ SelectSyntax

    📄️ FunctionsSingle Row Functions

    📄️ Data SubscriptionThe information in this document is related to the TDengine data subscription feature.

    📄️ OperatorsArithmetic Operators

    📄️ Name and Size LimitsNaming Rules

    📄️ ClusterThe 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.

    📄️ StatisticsTDengine includes a built-in database named PERFORMANCESCHEMA to provide access to database performance statistics. This document introduces the tables of PERFORMANCESCHEMA and their structure.

    📄️ Access ControlManage user and user’s permission

    📄️ Changes in TDengine 3.0This document explains how TDengine SQL has changed in version 3.0.