使用influx控制台工具操作InfluxDB
这里记录下influx控制台的简单使用,如需更多功能请参考InfluxDB官方文档: https://docs.influxdata.com/influxdb/v1.1/
环境: CentOS6.5_x64
InfluxDB版本:1.1.0
准备工作
- 启动服务器
执行如下命令:
service influxdb start
示例如下:
[root@localhost ~]# service influxdb start
Starting influxdb...
influxdb process was started [ OK ]
[root@localhost ~]#
- 启动控制台客户端
在控制台执行influx即可启动InfluxDB cli,示例如下:
[root@localhost ~]# influx
Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
Connected to http://localhost:8086 version 1.1.0
InfluxDB shell version: 1.1.
>
influx控制台基本操作
数据库操作
- 显示已存在的所有数据库
格式: show databases
示例如下:
> show databases;
name: databases
name
----
_internal
- 创建新数据库
格式:
create database <dbname>
说明:
dbname : 数据库名称
示例如下:
> create database testdb;
> show databases;
name: databases
name
----
_internal
testdb
>
- 删除数据库
格式:
drop database <dbname>
说明:
dbname : 数据库名称
示例如下:
> drop database testdb;
> show databases;
name: databases
name
----
_internal >
表操作
- 显示指定数据库中已存在的表
格式: show measurements
示例如下:
> use testdb;
Using database testdb
> show measurements;
- 创建新表并添加数据
InfluxDB没有提供单独的建表语句,可以通过以下方式创建数据库并添加数据。
格式:
insert <tbname>,<tags> <values> [timestamp]
说明:
tbname : 数据表名称
tags : 表的tag域
values : 表的value域
timestamp :当前数据的时间戳(可选,没有提供的话系统会自带添加)
示例如下:
> use testdb;
Using database testdb
> insert students,stuid=s123 score=
> show measurements;
name: measurements
name
----
students
- 删除表
格式:
drop measurement <tbname>
说明:
tbname : 数据表名称
示例如下:
> use testdb;
Using database testdb
> drop measurement students;
> show measurements;
>
数据操作
- 添加
格式:
insert <tbname>,<tags> <values> [timestamp]
说明:
tbname : 数据表名称
tags : 表的tag域
values : 表的value域
timestamp :当前数据的时间戳(可选,没有提供的话系统会自带添加)
示例如下:
> insert students,stuid=s123 score=
> insert students,stuid=s123 score=
> select * from students
name: students
time score stuid
---- ----- -----
s123
s123
- 查询
格式:
select <fields> from <tbname> [ into_clause ] [ where_clause ]
[ group_by_clause ] [ order_by_clause ] [ limit_clause ]
[ offset_clause ] [ slimit_clause ] [ soffset_clause ]
说明:
fields : 要查询的字段,查询全部可以用*
tbname : 数据表名称
into_clause : select ... into (可选)
where_clause : where条件域(可选)
group_by_clause : group by相关(可选)
order_by_clause : order by相关(可选)
limit_clause : limit相关(可选)
offset_clause : offset相关(可选)
slimit_clause : slimit相关(可选)
soffset_clause : soffset相关(可选)
示例如下:
> use testdb;
Using database testdb
> show measurements;
name: measurements
name
----
students > select * from students
name: students
time score stuid
---- ----- -----
s123
s123
s123
s123 > select * from students where score > ;
name: students
time score stuid
---- ----- -----
s123
s123 > select * from students where score > limit ;
name: students
time score stuid
---- ----- -----
s123 >
- 更新
tags 和 timestamp相同时数据会执行覆盖操作,相当于InfluxDB的更新操作。
示例如下:
> insert students,stuid=s123 score=
> select * from students
name: students
time score stuid
---- ----- -----
s123 > insert students,stuid=s123 score=
> select * from students
name: students
time score stuid
---- ----- -----
s123 >
- 删除
格式:
delete from <tbname> [where_clause]
说明:
tbname : 表名称
where_clause : where条件(可选)
删除所有数据:
> delete from students;
> select * from students;
>
删除指定条件的数据:
> select * from students;
name: students
time score stuid
---- ----- -----
s123
s123 > delete from students where stuid='s123' and time=;
> select * from students;
name: students
time score stuid
---- ----- -----
s123 >
其它
- 控制台执行单次查询
格式:
influx -execute '<query>'
类似 mysql -e 的功能,示例代码如下:
[root@localhost ~]# influx -execute 'show databases'
name: databases
name
----
_internal
testdb [root@localhost ~]#
- 指定查询结果以csv或json格式输出
格式:
influx -format=[format]
说明:
format : 启动格式,支持column,csv,json三种格式,默认为column
示例如下:
[root@localhost ~]# influx -format=csv
Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
Connected to http://localhost:8086 version 1.1.0
InfluxDB shell version: 1.1.
> show databases;
name,name
databases,_internal
databases,testdb
> exit
[root@localhost ~]# influx -format=json
Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
Connected to http://localhost:8086 version 1.1.0
InfluxDB shell version: 1.1.
> show databases;
{"results":[{"series":[{"name":"databases","columns":["name"],"values":[["_internal"],["testdb"]]}]}]}
> exit
[root@localhost ~]# influx -format=json -pretty
Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
Connected to http://localhost:8086 version 1.1.0
InfluxDB shell version: 1.1.
> show databases;
{
"results": [
{
"series": [
{
"name": "databases",
"columns": [
"name"
],
"values": [
[
"_internal"
],
[
"testdb"
]
]
}
]
}
]
}
>
好,就这些了,希望对你有帮助。
本文github地址:
https://github.com/mike-zhang/mikeBlogEssays/blob/master/2017/20170307_使用influx控制台工具操作InfluxDB.md
欢迎补充
使用influx控制台工具操作InfluxDB的更多相关文章
- Go操作influxDB
influxDB 安装 下载 https://portal.influxdata.com/downloads/ 这里需要注意因为这个网站引用了google的api所以国内点页面的按钮是没反应的,怎 ...
- GO学习-(28) Go语言操作influxDB
Go语言操作influxDB 本文介绍了influxDB时序数据库及Go语言操作influxDB. InfluxDB是一个开源分布式时序.事件和指标数据库.使用Go语言编写,无需外部依赖.其设计目标是 ...
- 使用curl操作InfluxDB
这里列举几个简单的示例代码,更多信息请参考InfluxDB官方文档: https://docs.influxdata.com/influxdb/v1.1/ 环境: CentOS6.5_x64Influ ...
- 使用python操作InfluxDB
环境: CentOS6.5_x64InfluxDB版本:1.1.0Python版本 : 2.6 准备工作 启动服务器 执行如下命令: service influxdb start 示例如下: [roo ...
- Python 使用Python远程连接并操作InfluxDB数据库
使用Python远程连接并操作InfluxDB数据库 by:授客 QQ:1033553122 实践环境 Python 3.4.0 CentOS 6 64位(内核版本2.6.32-642.el6.x86 ...
- Python操作Influxdb数据库
1.influxdb基本操作[root@test ~]# wget https://dl.influxdata.com/influxdb/releases/influxdb-1.2.4.x86_64. ...
- 使用C语言操作InfluxDB
环境: CentOS6.5_x64 InfluxDB版本:1.1.0 InfluxDB官网暂未提供C语言开发库,但github提供的有: https://github.com/influxdata/i ...
- arcconf工具操作手册V1.0
arcconf工具操作手册 1.1.1 arcconf工具初始化和去初始化硬盘 [命令功能] PMC阵列卡系统下初始化硬盘,可以将raw盘状态变成ready状态,以便进一步组建raid和设置热备盘: ...
- Android ADB工具-操作手机和获取手设备信息(四)
Android ADB工具-操作手机和获取手设备信息(四) 标签(空格分隔): Android ADB 6. 其它命令 命令 功能 adb shell input text <content&g ...
随机推荐
- putty adb
putty.exe -adb -P 5037 transport-usb 网络调试也是可以的 先connect 再执行上面的命令 http://files.cnblogs.com/files/ahuo ...
- 好用的批量改名工具——文件批量改名工具V2.0 绿色版
我找了一个绿色免安装的软件来实现批量改名要求 下载地址:http://www.orsoon.com/Soft/14049.html#xiazai 添加图片后,开始改名.通过输入a#就可以将这些图片进行 ...
- 使用Python读取Mp3的标签信息
什么是ID3 MP3是音频文件最流行的格式,它的全称是 MPEG layer III.但是这种格式不支持对于音频内容的描述信息,包括歌曲名称.演唱者.专辑等等. 因此在1996年,Eric Kemp在 ...
- npm ERR! Error extracting ~/.npm/cloudant/1.9.0/package.tgz archive: ENOENT: no such file or directory, open '~/.npm/cloudant/1.9.0/package.tgz'
修改package.json Thanks machines returning the above error when , just and now all the builds are pass ...
- java实时监听日志写入kafka(转)
原文链接:http://www.sjsjw.com/kf_cloud/article/020376ABA013802.asp 目的 实时监听某目录下的日志文件,如有新文件切换到新文件,并同步写入kaf ...
- windows核心编程-互斥器(Mutexes)
线程同步的方式主要有:临界区.互斥区.事件.信号量四种方式. 前边讲过了临界区线程同步-----windows核心编程-关键段(临界区)线程同步,这章我来介绍一下互斥器(Mutexes)在线程同步中的 ...
- DevExpress的安装方法与破解教程【转】
DevExpress是一个界面控件套件,提供了一系列的界面控件套件的DotNet界面控件.DevExpress开发的控件有很强的实力,不仅功能丰富,应用简单,而且界面华丽,更可方便订制,对于编程人员来 ...
- JavaScript 覆盖document.createElement 方法
最近项目遇到了问题,有个asp.net web程序只能在IE7 运行,现在xp都淘汰了,大家都用IE8-IE11,因此这个web app也需要升级 适应所有IE版本.照成IE版本不兼容的问题主要来致d ...
- 【Error】centos7 minimal connect: Network is unreachable
参考链接:http://www.centoscn.com/CentosBug/osbug/2015/1208/6500.html 由于centos7 和之前的版本差异比较大,之前的一些命令不能完全使用 ...
- GDB 程序调试简单实践
用了好久的GCC/G++ 却一直都没用过GDB调试过程序,有时程序不是非常大,一般有错,直接看编译器编译结果就几乎相同知道错在哪儿了,或者使用codeblocks单步调试,甚至回到windows以下调 ...