这里记录下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的更多相关文章

  1. Go操作influxDB

      influxDB 安装 下载 https://portal.influxdata.com/downloads/ 这里需要注意因为这个网站引用了google的api所以国内点页面的按钮是没反应的,怎 ...

  2. GO学习-(28) Go语言操作influxDB

    Go语言操作influxDB 本文介绍了influxDB时序数据库及Go语言操作influxDB. InfluxDB是一个开源分布式时序.事件和指标数据库.使用Go语言编写,无需外部依赖.其设计目标是 ...

  3. 使用curl操作InfluxDB

    这里列举几个简单的示例代码,更多信息请参考InfluxDB官方文档: https://docs.influxdata.com/influxdb/v1.1/ 环境: CentOS6.5_x64Influ ...

  4. 使用python操作InfluxDB

    环境: CentOS6.5_x64InfluxDB版本:1.1.0Python版本 : 2.6 准备工作 启动服务器 执行如下命令: service influxdb start 示例如下: [roo ...

  5. Python 使用Python远程连接并操作InfluxDB数据库

    使用Python远程连接并操作InfluxDB数据库 by:授客 QQ:1033553122 实践环境 Python 3.4.0 CentOS 6 64位(内核版本2.6.32-642.el6.x86 ...

  6. Python操作Influxdb数据库

    1.influxdb基本操作[root@test ~]# wget https://dl.influxdata.com/influxdb/releases/influxdb-1.2.4.x86_64. ...

  7. 使用C语言操作InfluxDB

    环境: CentOS6.5_x64 InfluxDB版本:1.1.0 InfluxDB官网暂未提供C语言开发库,但github提供的有: https://github.com/influxdata/i ...

  8. arcconf工具操作手册V1.0

    arcconf工具操作手册 1.1.1  arcconf工具初始化和去初始化硬盘 [命令功能] PMC阵列卡系统下初始化硬盘,可以将raw盘状态变成ready状态,以便进一步组建raid和设置热备盘: ...

  9. Android ADB工具-操作手机和获取手设备信息(四)

    Android ADB工具-操作手机和获取手设备信息(四) 标签(空格分隔): Android ADB 6. 其它命令 命令 功能 adb shell input text <content&g ...

随机推荐

  1. @Transactional事务几点注意

    这里面有几点需要大家留意:A. 一个功能是否要事务,必须纳入设计.编码考虑.不能仅仅完成了基本功能就ok.B. 如果加了事务,必须做好开发环境测试(测试环境也尽量触发异常.测试回滚),确保事务生效.C ...

  2. Charles抓包https

    Charles抓包https 灰灰是只小贱狗 2018.05.08 10:46 字数 762 阅读 7800评论 3喜欢 3 抓取HTTPS请求包,对数据进行排查检验 1.安装Charles 2.电脑 ...

  3. X、Y轴抖动的动画

    实现这个动画效果用到了interpolator属性,这样就能让一些控件产生自定义的抖动效果 这是用作interpolator的文件,用来做动画循环 cycle.xml <?xml version ...

  4. [Android Security] 反编译常用工具

    copy : https://down.52pojie.cn/Tools/Disassemblers/

  5. Chapter 3 -- Ordering

    Guava's fluent comparator class, Ordering, explained. explained Updated Jun 27, 2013 by cpov...@goog ...

  6. nodejs中thiskeyword的问题

    再分析详细内容之前,必需要好好阅读下面下面两篇blog 学习Javascript闭包(closure) Javascript的this使用方法 这两篇文章是阮一峰老师对Javascript的闭包和th ...

  7. JAVA 是否会发生内存泄露(转)

    原文链接: JAVA 是否会发生内存泄露 几次面试,面试官都问到了这个问题,于是搜集了答案.总结出虽然java自身有垃圾回收机制,但是很多情况下还是发生内存泄露的. java导致内存泄露的原因很明确: ...

  8. frp错误处理:login to server failed: authorization failed

    frp使用过程中会出现各种错误信息,有些朋友不太清楚,打算记录一些常见的错误返回代码,这里介绍一下frpc客户端[W] [control.go:111] login to server failed: ...

  9. 第一章 Typescript 介绍

    Typescript 介绍 一.Typescript 简介 Typescript 是微软开发的 Javascript 的超集,Typescript 兼容 Javascript,可以载入 Javascr ...

  10. RV LayoutManager 流式布局 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...