【翻译】TDengine用户文档翻译

前言

TDengine是最近比较轰动的项目,官方主打的方向是物联网大数据,口号是比hadoop快十倍,因为是国人开源的物联网大数据平台,刚好自己也在找hadoop的替代品,所以打算研究一下TDengine,于是特意翻译了TDengine的githup文档,如果有不妥的地方欢迎指正。

文档

TDengine是一个存储,查询和分析时序数据高可用的平台,他的工作模式有点像关系型数据库,但强烈建议您在体验之前阅读以下文档

开始

快速开始

花费几分钟下载、安装和体验TDengine

目前,TDengine仅仅是运行在Linux上, 你可以选择用源码或者包的方式安装他,下载和安装成功仅仅需要花费几分钟。

用源码方式安装
请访问我们的githup的源码安装页,地址为https://github.com/taosdata/TDengine。

包方式安装
有三个类型包,请选择你想要的其中之一
TDengine RPM 包 (1.5M)
TDengine DEB 包 (1.7M)
TDengine 源码包 (3.0M)

目前,TDengine仅仅支持安装在systemd作为服务管理器的Linux系统上,使用以下命令检查您的系统是否包含systemd

which systemd或者是whereis systemd

如果systemd没找到,请安装源码方式安装

运行TDengine

安装完毕以后,使用systemctl开启TDengine服务进程

systemctl start taosd

然后检查下服务进程是否正常运行

systemctl status taosd

如果服务正常运行中,你就可以使用taos命令访问TDengine,taos是保存在/usr/local/bin/taos中一个接口工具

TDengine Shell

要执行TDengine shell需要在Linux下执行

taos

假如shell连接成功了TDengine ,是会打印出来欢迎信息的,否则呢会打印出来错误信息

In the TDengine shell, you can create databases, create tables and insert/query data with SQL. Each query command ends with a semicolon. It works like MySQL, for example:
在TDengine shell中,你可以使用sql创建数据库,创建表和插入查询数据,每一个查询命令使用分号结尾,他的工作模式有点像mysql,比如

create database db;
use db;
create table t (ts timestamp, cdata int);
insert into t values ('2019-07-15 10:00:00', 10);
insert into t values ('2019-07-15 10:01:05', 20);
select * from t;
          ts          |   speed   |
===================================
 19-07-15 10:00:00.000|         10|
 19-07-15 10:01:05.000|         20|
Query OK, 2 row(s) in set (0.001700s)

使用SQL命令,系统管理员可以检查系统状态,增加和删除用户权限以及管理服务器。

Shell 命令行参数

你可以在taos添加参数来满足你的实际需要,常用参数列表如下:

-c, --config-dir: set the configuration directory. It is /etc/taos by default
-h, --host: set the IP address of the server it will connect to, Default is localhost
-s, --commands: set the command to run without entering the shell
-u, – user: user name to connect to server. Default is root
-p, --password: password. Default is ‘taosdata’
-?, --help: get a full list of supported options

例如:

taos -h 192.168.0.1 -s "use db; show tables;"

运行批量命令

taos> source ;

tips:
使用上下键查看历史命令
使用alter user更改用户默认密码
ctrl+c终止任何查询
使用RESET QUERY CACHE命令清理表或者是STables缓存

主要特点

TDengine 的核心功能是一个时序数据库,为了降低开发和管理的复杂性,进一步提高系统效率,TDEngine还提供缓存、发布/子消息传递系统和流计算功能。它为物联网大数据平台提供了一个完整的堆栈。具体功能如下:

  1. 使用类SQL语言插入和查询数据
  2. 支持C/C++, Java(JDBC), Python, Go 语言的REST接口开发
  3. 通过python/r/matlab或tdengine shell进行及时查询/分析
  4. 支持基于滑动窗口的流计算的连续查询
  5. 超级表,可灵活高效地聚合多个时间流
  6. 在一个时间窗口内对一个或多个时间流进行聚合
  7. 支持发布者/订阅者模型的内置消息传递系统
  8. 为每个时间流内置缓存,使最新数据以光速提供
  9. 历史数据和实时数据的透明处理
  10. 与Telegraf、Grafana等工具无缝集成
  11. 管理TDEngine的一组工具或配置

对于企业级的版本,提供以下功能

  1. 线性可扩展性,提供更高的容量/吞吐量
  2. 高可用性,保证运营商级服务
  3. 跨多个地理站点的节点之间的内置复制
  4. 多层存储,使历史数据管理更简单、经济高效
  5. 基于Web的管理工具和其他使维护更简单的工具

TDEngine是专为物联网、联网汽车、工业物联网、IT基础设施和应用程序监控等场景中的时间序列数据处理而设计和优化的。与其他解决方案相比,插入/查询速度快10倍。使用单核机器,可以处理超过20K个请求,可以接收数百万个数据点,一秒钟内可以检索超过1000万个数据点。通过基于列的存储和针对不同数据类型调整的压缩算法,所需的存储空间不足1/10。

数据模型和体系结构

数据模型

典型的物联网场景,会有很多类型的设备,每一个设备会采集一条或者多条监控项,这样子数据格式类似于以下表格:
【翻译】TDengine用户文档翻译_第1张图片
每一条记录包含设备ID,时间戳,监控项和一些静态的标签。每个设备在预先定义的计时器中生成数据记录或由事件触发。它是一系列数据点,就像一条流。

数据特征

作为一系列随时间变化的数据点,由设备、传感器、服务器或应用程序生成的数据点具有很强的共性。

  1. 监控项通常是结构化数据
  2. 很少对收集的数据进行删除/更新操作;
  3. 一个设备或传感器只有一个单一的数据源;
  4. 读写比例远低于典型的互联网应用;
  5. 用户关注的是数据的趋势,而不是特定时间的特定值;
  6. 总是有一个数据保留策略;
  7. 数据查询总是在给定的时间范围和设备的子集中执行;
  8. 必须进行实时聚合或分析;
  9. 根据设备数量和采样频率预测交通量;
  10. 数据量巨大,一个系统一天可以产生100亿个数据点。

TDENGINE利用上述特点,对时间序列数据进行了特殊优化的存储计算引擎设计。系统效率显著提高。

关系型数据库模型

由于时间序列数据更有可能是结构化数据,因此TDEngine采用传统的关系数据库模型对其进行处理。您需要创建一个数据库,用模式定义创建表,然后插入数据点并执行查询来探索数据。使用标准的SQL,没有学习曲线。

一个设备一张表

由于不同的网络延时,来自不同设备的数据点可能顺序错误地到达服务器,如果系统设计的完善的话,但是对于同一台设备的数据应该是按照顺序到达服务器的,利用这一特殊功能,TDEngine要求用户为每个设备(时间流)创建一个表。例如,如果智能电表超过10000个,则应创建10000个表。对于上表,应为设备D1001、D1002、D1003和D1004创建4个表,以存储收集的数据。

这一强大的需求可以保证设备的数据点可以被逐块保存在连续内存/硬盘空间中。如果查询只在一个时间范围内的一个设备上应用,那么这种设计将显著减少读取延迟,因为整个块由一个设备拥有。此外,写延迟也可以显著降低,因为同一设备生成的数据点将按顺序到达,新的数据点将简单地附加到一个块中。缓存块大小和文件块中的记录行可以配置为适合场景。

最佳实践

表:TDENGINE建议使用设备ID作为表名(如上图中的D1001)。每个设备可以收集一个或多个度量(如图中的值1、值2、值3)。每个度量在表中都有一列,该度量名称可以用作列名称。列的数据类型可以是int、float、double、tinyint、bigint、bool或binary。有时,一个设备可能有多个度量组,每个组有不同的采样周期,您应该为每个组为每个设备创建一个表。表中的第一列必须是时间戳。tdEngine使用时间戳作为索引,不会根据存储的任何度量构建索引。

超级表:为了有效地支持多个表上的聚合,TDEngine引入了(超级表)概念。使用一个超级表来表示同一类型的设备。模式用于定义收集的度量(如图中的value1、value2、value3),标记用于定义每个表或设备的静态属性(如图中的tag1、tag2)。表是通过具有特定标记值的stable创建的。可以通过筛选标记值来聚合超级表中的所有表或表的子集。

数据库:不同类型的设备可能会以不同的模式生成数据点,并进行不同的处理。例如,采样频率、数据保留策略、复制数、缓存大小、记录大小、压缩算法可能不同。为了提高系统的效率,TDEngine建议为不同的场景创建具有独特配置的不同数据库。

无模式vs模式:与NoSQL数据库相比,由于要在插入数据点之前创建一个具有模式定义的表,灵活性不太好,尤其是在模式更改时。但在大多数物联网场景中,模式定义良好且很少更改,灵活性的丧失不会给开发人员或管理员带来很大的痛苦。TDEngine允许应用程序在一秒钟内更改模式,即使在必须更改模式时有大量的历史数据。
TDEngine不限制表、稳定库或数据库的数量。您可以创建任意数量的稳定或数据库来适应场景。

体系结构

TDengine server 只要包含两个重要的模块,MGMT和DNODE,完整的TDengine 还包含一个TDengine 客户端模块

【翻译】TDengine用户文档翻译_第2张图片

MGMT模块

管理模块处理元数据的存储和查询,其中包括有关用户、数据库和表的信息。在连接TDEngine服务器时,应用程序将首先连接到管理模块。创建/删除数据库/表时,首先将请求发送到管理模块以创建/删除元数据。然后,管理模块将向数据模块发送请求,以分配/释放所需的资源。在编写或查询的情况下,应用程序仍然需要访问mgmt模块来获取元数据,然后根据元数据访问dnode模块。

DNODE模块

dnode模块负责数据的存储和查询。为了将来的扩展和高效的资源使用,TDEngine对其使用的资源应用虚拟化。TDEngine引入了虚拟节点(vnode)的概念,它是存储、资源分配和数据复制(Enterprise Edition)的单元。如图2所示,TDEngine将每个数据节点视为Vnode的聚合。

创建数据库时,系统将分配一个Vnode。每个Vnode包含多个表,但一个表只属于一个Vnode。每个数据库都有一个或模式Vnode,但一个Vnode只属于一个数据库。每个Vnode包含一组表中的所有数据。Vnode有自己的缓存、存储数据的目录。不同Vnode之间的资源是互斥的,不管是缓存还是文件目录。但是,同一个Vnode中的资源在它的所有表之间共享。通过虚拟化,TDEngine可以合理地将资源分配到每个Vnode,提高资源利用率和并发性。一个dnode上的Vnode数量可以根据其硬件资源进行配置。

【翻译】TDengine用户文档翻译_第3张图片

Client模块

TDEngine客户机模块接受来自应用程序的请求(主要是SQL形式),并将请求转换为内部表示并发送到服务器端。TDEngine支持多个接口,这些接口都构建在TDEngine客户机模块之上。

对于客户端与管理模块之间的通信,使用TCP/UDP,端口由系统配置文件taos.cfg中的参数mgmtshellport设置,默认值为6030。对于客户端和dnode模块之间的通信,使用TCP/UDP,端口由系统配置文件中的参数vnodeshellport设置,默认值为6035。

写进程

图3显示了TDEngine的完整写入过程。TDEngine使用提前写入日志策略来确保数据的安全性和完整性。从客户机接收的数据首先写入提交日志。当TDEngine从断电或其他情况导致的崩溃中恢复时,提交日志用于恢复数据。写入提交日志后,数据将被写入相应的Vnode缓存,然后向应用程序发送确认。有两种机制可以将缓存中的数据刷新到磁盘以进行持久存储:

Flush driven by timer:
有一个后端计时器定期将缓存中的数据刷新到磁盘。周期可通过系统配置文件taos.cfg中的参数committime进行配置。

Flush driven by data:
当左缓冲区大小低于阈值时,缓存中的数据也会刷新到磁盘。由数据驱动的刷新可以重置由计时器驱动的刷新计时器

【翻译】TDengine用户文档翻译_第4张图片
当提交过程开始时,将打开新的提交日志文件。提交过程完成后,将删除旧的提交文件

数据存储

TDENGINE数据默认保存在/var/lib/taos目录中。通过在系统配置文件taos.cfg中设置参数datadir,可以将其更改为其他目录。

TDEngine的元数据包括数据库、表、用户、超级表和标记信息。为了减少延迟,元数据都在缓存中缓冲。

表中保存的数据记录根据时间范围进行分片。在某个时间范围内,同一Vnode中的表的数据保存在同一个文件组中。这种分片策略可以有效地提高数据搜索速度。默认情况下,一组文件包含10天内的数据,可以通过配置文件中的daysperfile或create database子句中的days关键字进行配置。

一旦数据记录的生命周期结束,它们就会被自动删除。寿命可通过系统配置文件中的参数daystokeep进行配置。默认值为3650天。

文件中的数据是分块的。数据块只包含一个表的数据。同一数据块中的记录根据主时间戳进行排序。为了提高压缩率,记录按列存储,并根据每列的数据类型采用不同的压缩算法。

TAOS SQL

TDengine provides a SQL like query language to insert or query data. You can execute the SQL statements through TDengine Shell, or through C/C++, Java(JDBC), Python, Restful, Go APIs to interact with the taosd service.

Before reading through, please have a look at the conventions used for syntax descriptions here in this documentation.

Squared brackets ("[]") indicate optional arguments or clauses
Curly braces ("{}") indicate that one member from a set of choices in the braces must be chosen
A single verticle line ("|") works a separator for multiple optional args or clauses
Dots ("…") means repeating for as many times

Data Types

Timestamp
The timestamp is the most important data type in TDengine. The first column of each table must be TIMESTAMP type, but other columns can also be TIMESTAMP type. The following rules for timestamp:

String Format: ‘YYYY-MM-DD HH:mm:ss.MS’, which represents the year, month, day, hour, minute and second and milliseconds. For example,‘2017-08-12 18:52:58.128’ is a valid timestamp string. Note: timestamp string must be quoted by either single quote or double quote.
Epoch Time: a timestamp value can also be a long integer representing milliseconds since the epoch. For example, the values in the above example can be represented as an epoch 1502535178128 in milliseconds. Please note the epoch time doesn’t need any quotes.
Internal FunctionNOW : this is the current time of the server
If timestamp is 0 when inserting a record, timestamp will be set to the current time of the server
Arithmetic operations can be applied to timestamp. For example: now-2h represents a timestamp which is 2 hours ago from the current server time. Units include a (milliseconds), s (seconds), m (minutes), h (hours), d (days), w (weeks), n (months), y (years). NOW can be used in either insertions or queries.
Default time precision is millisecond, you can change it to microseocnd by setting parameter enableMicrosecond in system configuration. For epoch time, the long integer shall be microseconds since the epoch. For the above string format, MS shall be six digits.

Data Types
The full list of data types is listed below. For string types of data, we will use M to indicate the maximum length of that type.

Data Type	Bytes	Note

1 TINYINT 1 A nullable integer type with a range of [-127, 127]
2 SMALLINT 2 A nullable integer type with a range of [-32767, 32767]
3 INT 4 A nullable integer type with a range of [-2^{31}+1, 2^{31}-1 ]
4 BIGINT 8 A nullable integer type with a range of [-2^{59}, 2^{59} ]
5 FLOAT 4 A standard nullable float type with 6 -7 significant digits and a range of [-3.4 e 38, 3.4 e 38]
6 DOUBLE 8 A standard nullable double float type with 15-16 significant digits and a range of [-1.7e308, 1.7e308]
7 BOOL 1 A nullable boolean type, [true, false]
8 TIMESTAMP 8 A nullable timestamp type with the same usage as the primary column timestamp
9 BINARY(M) M A nullable string type whose length is M, any exceeded chars will be automatically truncated. This type of string only supports ASCii encoded chars.
10 NCHAR(M) 4 * M A nullable string type whose length is M, any exceeded chars will be truncated. The NCHAR type supports Unicode encoded chars.

All the keywords in a SQL statement are case-insensitive, but strings values are case-sensitive and must be quoted by a pair of ’ or ". To quote a ’ or a " , you can use the escape character .

Database Management

Create a Database

CREATE DATABASE [IF NOT EXISTS] db_name [KEEP keep]

Option: KEEP is used for data retention policy. The data records will be removed once keep-days are passed. There are more parameters related to DB storage, please check system configuration.

Use a Database

USE db_name

Drop a Database

DROP DATABASE [IF EXISTS] db_name

List all Databases

SHOW DATABASES

Table Management

Create a Table

CREATE TABLE [IF NOT EXISTS] tb_name (timestamp_field_name TIMESTAMP, field1_name data_type1 [, field2_name data_type2 …])

Note: 1) the first column must be timstamp, and system will set it as the primary key; 2) the record size is limited to 4096 bytes; 3) for binary or nachr data type, the length shall be specified, for example, binary(20), it means 20 bytes.

Drop a Table

DROP TABLE [IF EXISTS] tb_name

List all Tables

SHOW TABLES [LIKE tb_name_wildcar]

It shows all tables in the current DB. Note: wildcard character can be used in the table name to filter tables. Wildcard character: 1) ’%’ means 0 to any number of characters; 2)’_’ underscore means exactly one character.

Print Table Schema

DESCRIBE tb_name

Add a Column

ALTER TABLE tb_name ADD COLUMN field_name data_type

Drop a Column

ALTER TABLE tb_name DROP COLUMN field_name

If the table is created via Super Table, the schema can only be changed via STable. But for tables not created from STable, you can change their schema directly.

Tips: You can apply an operation on a table not in the current DB by concatenating DB name with the character ‘.’, then with table name. For example, ‘demo.tb1’ means the operation is applied to table tb1 in DB demo although demo is not the current selected DB.

插入记录

Insert a Record

INSERT INTO tb_name VALUES (field_value, ...);

Insert a data record into table tb_name

Insert a Record with Selected Columns

INSERT INTO tb_name (field1_name, ...) VALUES(field1_value, ...)

Insert a data record into table tb_name, with data in selected columns. If a column is not selected, the system will put NULL there. First column (time stamp ) could not be null, it must be there.

Insert a Batch of Records

INSERT INTO tb_name VALUES (field1_value1, ...) (field1_value2, ...)...;

Insert multiple data records to the table

Insert a Batch of Records with Selected Columns

INSERT INTO tb_name (field1_name, ...) VALUES(field1_value1, ...) (field1_value2, ...)

Insert Records into Multiple Tables

INSERT INTO tb1_name VALUES (field1_value1, ...)(field1_value2, ...)... 
            tb2_name VALUES (field1_value1, ...)(field1_value2, ...)...;

Insert data records into table tb1_name and tb2_name

Insert Records into Multiple Tables with Selected Columns

INSERT INTO tb1_name (tb1_field1_name, ...) VALUES (field1_value1, ...) (field1_value1, ...)
            tb2_name (tb2_field1_name, ...) VALUES(field1_value1, ...) (field1_value2, ...)

Note: For a table, the new record must have timestamp bigger than the last data record, otherwise, it will be thrown away. If timestamp is 0, the time stamp will be set to the system time on server.

IMPORT: If you do want to insert a historical data record into a table, use IMPORT command instead of INSERT. IMPORT has the same syntax as INSERT. If you want to import a batch of historical records, the records shall be ordered in the timestamp, otherwise, TDengine won’t handle it in the right way.

数据查询

Query Syntax:

SELECT {* | expr_list} FROM tb_name
    [WHERE where_condition]
    [ORDER BY _c0 { DESC | ASC }]
    [LIMIT limit [, OFFSET offset]]
    [>> export_file]
    
SELECT function_list FROM tb_name
    [WHERE where_condition]
    [LIMIT limit [, OFFSET offset]]
    [>> export_file]

To query a table, use * to select all data from a table; or a specified list of expressions expr_list of columns. The SQL expression can contain alias and arithmetic operations between numeric typed columns.
For the WHERE conditions, use logical operations to filter the timestamp column and all numeric columns, and wild cards to filter the two string typed columns.
Sort the result set by the first column timestamp _c0 (or directly use the timestamp column name) in either descending or ascending order (by default). “Order by” could not be applied to other columns.
Use LIMIT and OFFSET to control the number of rows returned and the starting position of the retrieved rows. LIMIT/OFFSET is applied after “order by” operations.
Export the retrieved result set into a CSV file using >>. The target file’s full path should be explicitly specified in the statement.

Supported Operations of Data Filtering:
【翻译】TDengine用户文档翻译_第5张图片
For two or more conditions, only AND is supported, OR is not supported yet.
For filtering, only a single range is supported. For example, value>20 and value<30 is valid condition, but value<20 AND value<>5 is invalid condition

Some Examples

CREATE TABLE tb1 (ts timestamp, col1 int, col2 float, col3 binary(50));
SELECT * FROM tb1 WHERE ts >= NOW - 1h;
SELECT * FROM tb1 WHERE ts > '2018-06-01 08:00:00.000' AND ts <= '2018-06-02 08:00:00.000' AND col3 LIKE '%nny' ORDER BY ts DESC;
SELECT (col1 + col2) AS 'complex_metric' FROM tb1 WHERE ts > '2018-06-01 08:00:00.000' and col2 > 1.2 LIMIT 10 OFFSET 5;
SELECT COUNT(*) FROM tb1 WHERE ts >= NOW - 10m AND col2 > 3.14 >> /home/testoutpu.csv;

STable: Super Table

“一台设备一表”设计可以显著提高单个设备的插入/查询性能。但是它有一个副作用,多个表的聚合变得困难。为了降低复杂性和提高效率,TDENGINE引入了一个新概念:(超级表)。

什么是超级表

stable是一种抽象的设备,是一种设备类型的模板。包含一组具有相同模式或数据结构的设备(表)。除了共享模式外,稳定程序还具有一组标记,例如模型、序列号等。标记用于记录设备的静态属性,并用于对一组设备(表)进行聚合。标记是表的元数据,可以添加、删除或更改。

tdEngine不会将标记保存为收集的数据点的一部分。相反,标记保存为元数据。每个表都有一组标记。为了提高查询性能,标记都被缓存和索引。一个表只能属于一个稳定程序,但一个稳定程序可以包含多个表。

和表格一样,您可以创建、显示、删除和描述马厩。表上的大多数查询操作也可以应用于stable,包括聚合和选择器函数。对于一个稳定的查询,如果没有标记过滤器,那么操作将应用于通过这个稳定创建的所有表。如果存在标记过滤器,则操作仅应用于满足标记过滤器条件的表的子集。使用标签将设备放入不同的组中进行聚合将非常方便。

创建一个超级表

CREATE TABLE  ( TIMESTAMP, field_name1 field_type,…) TAGS(tag_name tag_type, …)

引入了新的关键字“tags”,其中tag_name是标记名,tag_type是关联的数据类型。

备注:

  1. 所有标签的字节应小于512。
  2. 标记的数据类型不能是时间戳或NChar
  3. 标签名称应与字段名称不同。
  4. 标签名称不得与系统关键字相同
  5. 最大标签数为6

例如:

create table thermometer (ts timestamp, degree float) 
tags (location binary(20), type int)```

上面的语句创建了一个带有两个标记“location”和“type”的超级表温度计。

## 通过stable创建表格
要为设备创建一个表,可以使用stable作为其模板并分配标记值。语法是:

CREATE TABLE USING TAGS (tag_value1,…)

您可以通过一个稳定表创建任意数量的表,并且每个表可能具有不同的标记值。例如,通过下面的稳定温度计创建五个表:

create table t1 using thermometer tags (‘beijing’, 10);
create table t2 using thermometer tags (‘beijing’, 20);
create table t3 using thermometer tags (‘shanghai’, 10);
create table t4 using thermometer tags (‘shanghai’, 20);
create table t5 using thermometer tags (‘new york’, 10);


## 通过stable聚合表
通过指定标记筛选条件,可以将一组表组合在一起,然后应用聚合操作。可以根据标记值对结果集进行分组和排序。语法是:

SELECT function,…
FROM
WHERE <[=|<=|>=|<>] values…> ([AND|OR] …)
INTERVAL ()
GROUP BY ,
ORDER BY
SLIMIT
SOFFSET
LIMIT
OFFSET

目前,stable只支持以下聚合/选择函数:sum、count、avg、first、last、min、max、top、bottom和投影操作,语法与标准表相同。不支持算术运算,也不支持嵌入查询。间隔用于一个时间范围内的聚合。

加入GROUP BY没被用到,聚合是被用到表中所有的字段上,并且输出的结果集是按照时间的顺序排列的,但是你可以使用order by指定你需要排序的字段。

假如使用了GROUP BY ,则聚合是基于tags做分组的,每一个组都支持独立的聚合,结果集是一个聚合的结果组,组的排序是用order by tag_name。

SLIMIT/SOFFSET用于限制组的数量和定义开始组数

LIMIT/OFFSET被用于限制记录的数量和开始的行数

例 1:

SELECT COUNT(*), AVG(degree), MAX(degree), MIN(degree)
FROM thermometer
WHERE location=’beijing’ or location=’tianjing’
GROUP BY location, type

例2:

SELECT COUNT(*), AVG(degree), MAX(degree), MIN(degree)
FROM thermometer
WHERE name=’beijing’ and type=10 and ts>=now-1d
INTERVAL(10M)


## 自动创建表
加入之前表没被创建,插入的时候就会报错中。但是对于超级表呢,TDengine会自动创建一个不存在的表,语法如下:

INSERT INTO USING TAGS (, …) VALUES (field_value, …) (field_value, …) … USING TAGS(, …) VALUES (, …) …;


## 管理超级表
当你创建一个超级表以后,你可以描述、删除和更改一个超级表,这个章节列出支持的操作

## 在当前数据库中显示超级表

show stables;

描述超级表:
Describe a STable

删除超级表
Drop a STable

你可能感兴趣的:(java开发)