这里记录下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. Objective-C 入门笔记

    简介 建立在C语言之上,可以混编C/C++代码,编写一个类需要二个文件: .h的头文件 .m的实现文件(如果是C/C++混编文件,文件后缀为.mm) 既然有头文件,所以很多人会拿它与C++进行类比,它 ...

  2. JS读取json 文件

    json文件是一种轻量级的数据交互格式.一般在jquery中使用getJSON()方法读取. $.getJSON(url,[data],[callback]) url:加载的页面地址 data: 可选 ...

  3. Java| 编译和反编译

    原文链接: http://www.yveshe.com/articles/2018/05/01/1525172129089.html 什么是编程语言? 在介绍编译和反编译之前,我们先来简单介绍下编程语 ...

  4. MECE分析法(Mutually Exclusive Collectively Exhaustive)

    什么是MECE分析法? MECE,是Mutually Exclusive Collectively Exhaustive,中文意思是“相互独立,完全穷尽”. 也就是对于一个重大的议题,能够做到不重叠. ...

  5. [转]php cli命令 自定义参数传递

    FROM :http://www.cnblogs.com/zcy_soft/archive/2011/12/10/2283437.html 所有的PHP发行版,不论是编译自源代码的版本还是预创建的版本 ...

  6. Zookeeper Tutorial 2 -- Programmer's Guide

    数据模型 ZooKeeper跟分布式文件系统一样, 有一系列的命名空间. 唯一不同的地方是命名空间中的每个节点都有数据和他相关联. 它类似于一个允许文件同时是一个目录的文件系统. 节点的路径永远是以斜 ...

  7. [leetcode]Partition List @ Python

    原题地址:https://oj.leetcode.com/problems/partition-list/ 题意: Given a linked list and a value x, partiti ...

  8. [leetcode]Palindrome Partitioning II @ Python

    原题地址:https://oj.leetcode.com/problems/palindrome-partitioning-ii/ 题意: Given a string s, partition s  ...

  9. Valid Number leetcode java

    题目: Validate if a given string is numeric. Some examples: "0" => true " 0.1 " ...

  10. Java程序员须知的七个日志管理工具

    本文由 ImportNew - 赖 信涛 翻译自 takipiblog.欢迎加入翻译小组.转载请见文末要求. Splunk vs. Sumo Logic vs. LogStash vs. GrayLo ...