TDengine初搭建--第二版

taos> create database epiot;
Query OK, 0 of 0 row(s) in database (0.001805s)

taos> use epiot;
Database changed.

taos> create table device_tag(ts timestamp,tag1 int,tag2 float,tag3 int,current float,vlotage int,phase float);
Query OK, 0 of 0 row(s) in database (0.005699s)

taos> insert into device_tag values(now,1,2.2,3,1.6,220,0.8);
Query OK, 1 of 1 row(s) in database (0.001876s)

taos> insert into device_tag values(now,1,2.2,3,1.6,220,0.5);
Query OK, 1 of 1 row(s) in database (0.000497s)

taos> insert into device_tag values(now,1,2.2,3,1.6,223,0.6);
Query OK, 1 of 1 row(s) in database (0.000488s)

taos> select * from device_tag;
           ts            |    tag1     |         tag2         |    tag3     |       current        |   vlotage   |        phase         |
=========================================================================================================================================
 2022-01-12 20:13:26.389 |           1 |              2.20000 |           3 |              1.60000 |         220 |              0.80000 |
 2022-01-12 20:13:40.717 |           1 |              2.20000 |           3 |              1.60000 |         220 |              0.50000 |
 2022-01-12 20:14:01.964 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
Query OK, 3 row(s) in set (0.013866s)

taos> select count(*) from device_tag
   -> ;
       count(*)        |
========================
                     3 |
Query OK, 1 row(s) in set (0.002150s)



taos> insert into device_tag values(now,1,2.2,3,1.6,223,0.6);
Query OK, 1 of 1 row(s) in database (0.000491s)

taos> select avg(tag1) as tag1 ,sum(tag2) as tag2,max(current) as current ,max(vlotage) as voltage,min(phase) as phase from device_tag;
           tag1            |           tag2            |       current        |   voltage   |        phase         |
====================================================================================================================
               1.000000000 |              85.800001860 |              1.60000 |         223 |              0.50000 |
Query OK, 1 row(s) in set (0.001567s)

taos> select * from device_tag;
           ts            |    tag1     |         tag2         |    tag3     |       current        |   vlotage   |        phase         |
=========================================================================================================================================
 2022-01-12 20:13:26.389 |           1 |              2.20000 |           3 |              1.60000 |         220 |              0.80000 |
 2022-01-12 20:13:40.717 |           1 |              2.20000 |           3 |              1.60000 |         220 |              0.50000 |
 2022-01-12 20:14:01.964 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:33:43.871 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:33:51.673 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:33:54.717 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:33:57.041 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:33:59.194 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:34:01.000 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:34:02.707 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:34:04.345 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:34:05.765 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |


Query OK, 39 row(s) in set (0.001499s)

taos> select avg(tag1) as tag1 ,sum(tag2) as tag2,max(current) as current ,max(vlotage) as voltage,min(phase) as phase from device_tag where ts>'2022-01-12 20:34:43';
           tag1            |           tag2            |       current        |   voltage   |        phase         |
====================================================================================================================
               1.000000000 |               6.600000143 |              1.60000 |         223 |              0.60000 |
Query OK, 1 row(s) in set (0.002726s)

taos> select * from device_tag where ts>='2022-01-12 20:34:07';
           ts            |    tag1     |         tag2         |    tag3     |       current        |   vlotage   |        phase         |
=========================================================================================================================================
 2022-01-12 20:34:07.302 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:34:08.974 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:34:11.008 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:34:13.559 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:34:15.263 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:34:17.513 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:34:20.080 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:34:22.511 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |


taos> select * from device_tag where ts>='2022-01-12 20:34:20' and ts<='2022-01-12 20:34:30';
           ts            |    tag1     |         tag2         |    tag3     |       current        |   vlotage   |        phase         |
=========================================================================================================================================
 2022-01-12 20:34:20.080 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:34:22.511 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:34:25.280 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:34:26.943 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
 2022-01-12 20:34:29.040 |           1 |              2.20000 |           3 |              1.60000 |         223 |              0.60000 |
Query OK, 5 row(s) in set (0.001292s)

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Knight-Key

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值