index.md 2.1 KB
Newer Older
D
dingbo 已提交
1
---
陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
2 3
title: TDengine SQL
description: "The syntax supported by TDengine SQL "
D
dingbo 已提交
4 5
---

S
Sean Ely 已提交
6
This section explains the syntax to operating databases, tables, STables, inserting data, selecting data, functions and some tips that can be used in TDengine SQL. It would be easier to understand with some fundamental knowledge of SQL.
D
dingbo 已提交
7

S
Sean Ely 已提交
8
TDengine SQL is the major interface for users to write data into or query from TDengine. For users to easily use, syntax similar to standard SQL is provided. However, please note that TDengine SQL is not standard SQL. For instance, TDengine doesn't provide the functionality of deleting time series data, thus corresponding statements are not provided in TDengine SQL.
D
dingbo 已提交
9

陶建辉(Jeff)'s avatar
陶建辉(Jeff) 已提交
10
TDengine SQL doesn't support abbreviation for keywords, for example `DESCRIBE` can't be abbreviated as `DESC`.
D
dingbo 已提交
11

12
Syntax Specifications used in this chapter:
D
dingbo 已提交
13

14 15 16 17
- The content inside <\> needs to be input by the user, excluding <\> itself.
- \[ \] means optional input, excluding [] itself.
- | means one of a few options, excluding | itself.
- … means the item prior to it can be repeated multiple times.
D
dingbo 已提交
18

S
Sean Ely 已提交
19
To better demonstrate the syntax, usage and rules of TAOS SQL, hereinafter it's assumed that there is a data set of meters. Assuming each meter collects 3 data measurements: current, voltage, phase. The data model is shown below:
D
dingbo 已提交
20

21
```sql
D
dingbo 已提交
22 23 24 25 26 27 28 29 30 31 32
taos> DESCRIBE meters;
             Field              |        Type        |   Length    |    Note    |
=================================================================================
 ts                             | TIMESTAMP          |           8 |            |
 current                        | FLOAT              |           4 |            |
 voltage                        | INT                |           4 |            |
 phase                          | FLOAT              |           4 |            |
 location                       | BINARY             |          64 | TAG        |
 groupid                        | INT                |           4 | TAG        |
```

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