1.认证
influx
auth
admin
1qaz2wsx
2. 查看
show databases; 查看所有数据库
use data; 使用data这个数据库
show measurements 查看所有表
show tag keys 查看所有表中的索引tag
show field keys from cpu 查看cpu表中有哪些field字段
show tag keys from cpu 查看表中有哪些字段是tag
show series from cpu; 查询表中的点series
查询单表的10条数据
select * from data limit 10
查询表中的最大值
select max(*) from data
设置时间显示格式,按条件查询,这个是UTC时间
precision rfc3339
select * from CPU_ALL where time >= '2018-11-23 14:30:39' and time <= '2019-11-23 14:32:32' limit 10
需要在查询语句的最后加上tz('Asia/Shanghai'),这样查询的时间才是纠正为中国时区显示。
select * from CPU_ALL where time >= '2018-11-23 14:30:39' and time <= '2019-11-23 14:32:32' limit 10 tz('Asia/Shanghai')
查看某个时间下的数据
select * from CPU_ALL where "time" = 1551694910000000000
查询特定字段数据
select * from table_name where "字段1" =~ /匹配值/
倒序查询
select * from CPU_ALL order by time desc limit 10 tz('Asia/Shanghai')
查询平均值
select mean(*) from CPU_ALL tz('Asia/Shanghai')
3. 删除
drop measurement CPU_ALL 删除单表数据