数据库与表的操做数据库
#建立数据库 create database "db_name" #显示全部的数据库 show databases #删除数据库 drop database "db_name" #使用数据库 use db_name #显示该数据库中全部的表 show measurements #建立表,直接在插入数据的时候指定表名 insert test,host=127.0.0.1,monitor_name=test count=1 #删除表 drop measurement "measurement_name" #删除数据 show series from measurement_name delete from /.*/ where host =~ /elcndc5dsj\d\d/
查code
> use metrics Using database metrics > select * from test order by time desc
数据保存策略(Retention Policies)flux
#查看当前数据库Retention Policies show retention policies on "db_name" #建立新的Retention Policies create retention policy "rp_name" on "db_name" duration 3w replication 1 default rp_name:策略名 db_name:具体的数据库名 3w:保存3周,3周以前的数据将被删除,influxdb具备各类事件参数,好比:h(小时),d(天),w(星期) replication 1:副本个数,通常为1就能够了 default:设置为默认策略 #修改Retention Policies alter retention policy "rp_name" on "db_name" duration 30d default #删除Retention Policies drop retention policy "rp_name"
用户管理事件
#显示用户 show users #建立用户 create user "username" with password 'password' #建立管理员权限用户 create user "username" with password 'password' with all privileges #删除用户 drop user "username"