这里记录下influx控制台的简单使用,如需更多功能请参考InfluxDB官方文档: https://docs.influxdata.com/influxdb/v1.1/

环境: CentOS6.5_x64
InfluxDB版本:1.1.0

准备工作

  • 启动服务器

执行如下命令:

  1. service influxdb start

示例如下:

  1. [root@localhost ~]# service influxdb start
  2. Starting influxdb...
  3. influxdb process was started [ OK ]
  4. [root@localhost ~]#
  • 启动控制台客户端

在控制台执行influx即可启动InfluxDB cli,示例如下:

  1. [root@localhost ~]# influx
  2. Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
  3. Connected to http://localhost:8086 version 1.1.0
  4. InfluxDB shell version: 1.1.
  5. >

influx控制台基本操作

数据库操作

  • 显示已存在的所有数据库

格式: show databases
示例如下:

  1. > show databases;
  2. name: databases
  3. name
  4. ----
  5. _internal
  • 创建新数据库

格式:

  1. create database <dbname>

说明:
dbname : 数据库名称
示例如下:

  1. > create database testdb;
  2. > show databases;
  3. name: databases
  4. name
  5. ----
  6. _internal
  7. testdb
  8. >
  • 删除数据库

格式:

  1. drop database <dbname>

说明:
dbname : 数据库名称
示例如下:

  1. > drop database testdb;
  2. > show databases;
  3. name: databases
  4. name
  5. ----
  6. _internal
  7.  
  8. >

表操作

  • 显示指定数据库中已存在的表

格式: show measurements
示例如下:

  1. > use testdb;
  2. Using database testdb
  3. > show measurements;
  • 创建新表并添加数据

InfluxDB没有提供单独的建表语句,可以通过以下方式创建数据库并添加数据。

格式:

  1. insert <tbname>,<tags> <values> [timestamp]

说明:
tbname : 数据表名称
tags : 表的tag域
values : 表的value域
timestamp :当前数据的时间戳(可选,没有提供的话系统会自带添加)

示例如下:

  1. > use testdb;
  2. Using database testdb
  3. > insert students,stuid=s123 score=
  4. > show measurements;
  5. name: measurements
  6. name
  7. ----
  8. students
  • 删除表

格式:

  1. drop measurement <tbname>

说明:
tbname : 数据表名称

示例如下:

  1. > use testdb;
  2. Using database testdb
  3. > drop measurement students;
  4. > show measurements;
  5. >

数据操作

  • 添加

格式:

  1. insert <tbname>,<tags> <values> [timestamp]

说明:
tbname : 数据表名称
tags : 表的tag域
values : 表的value域
timestamp :当前数据的时间戳(可选,没有提供的话系统会自带添加)

示例如下:

  1. > insert students,stuid=s123 score=
  2. > insert students,stuid=s123 score=
  3. > select * from students
  4. name: students
  5. time score stuid
  6. ---- ----- -----
  7. s123
  8. s123
  • 查询

格式:

  1. select <fields> from <tbname> [ into_clause ] [ where_clause ]
  2. [ group_by_clause ] [ order_by_clause ] [ limit_clause ]
  3. [ 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相关(可选)

示例如下:

  1. > use testdb;
  2. Using database testdb
  3. > show measurements;
  4. name: measurements
  5. name
  6. ----
  7. students
  8.  
  9. > select * from students
  10. name: students
  11. time score stuid
  12. ---- ----- -----
  13. s123
  14. s123
  15. s123
  16. s123
  17.  
  18. > select * from students where score > ;
  19. name: students
  20. time score stuid
  21. ---- ----- -----
  22. s123
  23. s123
  24.  
  25. > select * from students where score > limit ;
  26. name: students
  27. time score stuid
  28. ---- ----- -----
  29. s123
  30.  
  31. >
  • 更新

tags 和 timestamp相同时数据会执行覆盖操作,相当于InfluxDB的更新操作。

示例如下:

  1. > insert students,stuid=s123 score=
  2. > select * from students
  3. name: students
  4. time score stuid
  5. ---- ----- -----
  6. s123
  7.  
  8. > insert students,stuid=s123 score=
  9. > select * from students
  10. name: students
  11. time score stuid
  12. ---- ----- -----
  13. s123
  14.  
  15. >
  • 删除

格式:

  1. delete from <tbname> [where_clause]

说明:
tbname : 表名称
where_clause : where条件(可选)

删除所有数据:

  1. > delete from students;
  2. > select * from students;
  3. >

删除指定条件的数据:

  1. > select * from students;
  2. name: students
  3. time score stuid
  4. ---- ----- -----
  5. s123
  6. s123
  7.  
  8. > delete from students where stuid='s123' and time=;
  9. > select * from students;
  10. name: students
  11. time score stuid
  12. ---- ----- -----
  13. s123
  14.  
  15. >

其它

  • 控制台执行单次查询

格式:

  1. influx -execute '<query>'

类似 mysql -e 的功能,示例代码如下:

  1. [root@localhost ~]# influx -execute 'show databases'
  2. name: databases
  3. name
  4. ----
  5. _internal
  6. testdb
  7.  
  8. [root@localhost ~]#
  • 指定查询结果以csv或json格式输出

格式:

  1. influx -format=[format]

说明:

format : 启动格式,支持column,csv,json三种格式,默认为column

示例如下:

  1. [root@localhost ~]# influx -format=csv
  2. Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
  3. Connected to http://localhost:8086 version 1.1.0
  4. InfluxDB shell version: 1.1.
  5. > show databases;
  6. name,name
  7. databases,_internal
  8. databases,testdb
  9. > exit
  10. [root@localhost ~]# influx -format=json
  11. Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
  12. Connected to http://localhost:8086 version 1.1.0
  13. InfluxDB shell version: 1.1.
  14. > show databases;
  15. {"results":[{"series":[{"name":"databases","columns":["name"],"values":[["_internal"],["testdb"]]}]}]}
  16. > exit
  17. [root@localhost ~]# influx -format=json -pretty
  18. Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
  19. Connected to http://localhost:8086 version 1.1.0
  20. InfluxDB shell version: 1.1.
  21. > show databases;
  22. {
  23. "results": [
  24. {
  25. "series": [
  26. {
  27. "name": "databases",
  28. "columns": [
  29. "name"
  30. ],
  31. "values": [
  32. [
  33. "_internal"
  34. ],
  35. [
  36. "testdb"
  37. ]
  38. ]
  39. }
  40. ]
  41. }
  42. ]
  43. }
  44. >

好,就这些了,希望对你有帮助。

本文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. Swift - UITableView展开缩放动画

    Swift - UITableView展开缩放动画 效果 源码 https://github.com/YouXianMing/Swift-Animations // // HeaderViewTapA ...

  2. ExtJS 4.2 教程-06:服务器代理(proxy)

    转载自起飞网,原文地址:http://www.qeefee.com/extjs-course-6-server-proxy ExtJS 4.2 教程-01:Hello ExtJS ExtJS 4.2 ...

  3. Button 自定义图片,代码绘制样式,添加音效的方法

    Button自己在xml文件中绑定监听器 <!-- 设定onclick属性,然后在activity中定义相应的方法 --> <!-- 通过xml布局中通过button的android ...

  4. [Web 前端] MobX

    1. 介绍 1.1. 原理 React的render是 状态 转化为树状结构的渲染组件的方法 而MobX提供了一种存储,更新 状态 的方法 React 和 MobX都在优化着软件开发中相同的问题. R ...

  5. 利用Bootstrap+Avalonjs+EntityFramework 开发ASP.NET WebForm应用程序(上)

    本文将介绍如何利用Bootstrap+Avalonjs+EntityFramework 开发ASP.NET WebForm应用程序,分为上下两篇.上篇主要介绍实现,下篇主要介绍界面. 打开Visual ...

  6. 东芝发布运行Win 10的AR眼镜,它和Google Glass企业版有哪些异同?

    https://www.leiphone.com/news/201803/Tw0nrq6vGDIvbmXr.html 雷锋网(公众号:雷锋网)获悉,3月13日,东芝发布新AR眼镜dynaEdge AR ...

  7. [leetcode]Restore IP Addresses @ Python

    原题地址:https://oj.leetcode.com/problems/restore-ip-addresses/ 题意: Given a string containing only digit ...

  8. 学习笔记:Maven的ArcheType的学习笔记

    摘要:     Archetype是什么?它由哪些文件组成?如何创建和安装自己的archtype,如何使用自己创建的archetype? 一.Archetype是什么     Archetype其实就 ...

  9. Java Math.sqrt()方法

    描述 java.lang.Math.sqrt(double a) 返回正确舍入的一个double值的正平方根.特殊情况: 如果参数是NaN或小于为零,那么结果是NaN. 如果参数是正无穷大,那么结果为 ...

  10. 微信小程序wxml文件中调用自定义函数

    想在微信小程序的wxml文件里自如的像vue那样调用自定义的方法,发现并不成功,得利用WXS脚本语言. WXS脚本语言是 WeiXin Script 脚本语言的简称,是JavaScript.JSON. ...