使用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 ...
随机推荐
- Swift - UITableView展开缩放动画
Swift - UITableView展开缩放动画 效果 源码 https://github.com/YouXianMing/Swift-Animations // // HeaderViewTapA ...
- ExtJS 4.2 教程-06:服务器代理(proxy)
转载自起飞网,原文地址:http://www.qeefee.com/extjs-course-6-server-proxy ExtJS 4.2 教程-01:Hello ExtJS ExtJS 4.2 ...
- Button 自定义图片,代码绘制样式,添加音效的方法
Button自己在xml文件中绑定监听器 <!-- 设定onclick属性,然后在activity中定义相应的方法 --> <!-- 通过xml布局中通过button的android ...
- [Web 前端] MobX
1. 介绍 1.1. 原理 React的render是 状态 转化为树状结构的渲染组件的方法 而MobX提供了一种存储,更新 状态 的方法 React 和 MobX都在优化着软件开发中相同的问题. R ...
- 利用Bootstrap+Avalonjs+EntityFramework 开发ASP.NET WebForm应用程序(上)
本文将介绍如何利用Bootstrap+Avalonjs+EntityFramework 开发ASP.NET WebForm应用程序,分为上下两篇.上篇主要介绍实现,下篇主要介绍界面. 打开Visual ...
- 东芝发布运行Win 10的AR眼镜,它和Google Glass企业版有哪些异同?
https://www.leiphone.com/news/201803/Tw0nrq6vGDIvbmXr.html 雷锋网(公众号:雷锋网)获悉,3月13日,东芝发布新AR眼镜dynaEdge AR ...
- [leetcode]Restore IP Addresses @ Python
原题地址:https://oj.leetcode.com/problems/restore-ip-addresses/ 题意: Given a string containing only digit ...
- 学习笔记:Maven的ArcheType的学习笔记
摘要: Archetype是什么?它由哪些文件组成?如何创建和安装自己的archtype,如何使用自己创建的archetype? 一.Archetype是什么 Archetype其实就 ...
- Java Math.sqrt()方法
描述 java.lang.Math.sqrt(double a) 返回正确舍入的一个double值的正平方根.特殊情况: 如果参数是NaN或小于为零,那么结果是NaN. 如果参数是正无穷大,那么结果为 ...
- 微信小程序wxml文件中调用自定义函数
想在微信小程序的wxml文件里自如的像vue那样调用自定义的方法,发现并不成功,得利用WXS脚本语言. WXS脚本语言是 WeiXin Script 脚本语言的简称,是JavaScript.JSON. ...