Use the influx console tool to operate the INFLUXDB

Source: Internet
Author: User
Tags influxdb

Here is a note of the simple use of the influx console, for more features please refer to INFLUXDB official documentation: HTTPS://DOCS.INFLUXDATA.COM/INFLUXDB/V1.1/

Environment: centos6.5_x64
Influxdb version: 1.1.0

Preparatory work
    • Start the server

Execute the following command:

Service Influxdb Start

Examples are as follows:

[Email protected] ~~]#
    • To start the console client

The Influxdb CLI can be started by executing influx in the console, as shown in the following example:

[Email protected] ~]# influxvisit https: // enterprise.influxdata.com to register for updates, InfluxDB Server management, and monitoring. Connected to http://localhost:8086 version 1.1.01.1. 0>
Influx console basic Operations database operations
    • Show all databases that already exist

Format: Show databases
Examples are as follows:

> show databases;name:databasesname----_internal
    • Create a new database

Format:

Create DATABASE <dbname>  

Description
dbname: Database name
Examples are as follows:

> CREATE database testdb; > show databases;name:databasesname----_internaltestdb>
    • Deleting a database

Format:

Drop Database <dbname>      

Description
dbname: Database name
Examples are as follows:

> drop database testdb; > show databases;name:databasesname----_internal>
Table Operations
    • Displays tables that already exist in the specified database

Format: Show measurements
Examples are as follows:

> Use testdb; Using database TestDB> show measurements;
    • Create a new table and add data

INFLUXDB does not provide a separate build table statement, you can create a database and add data in the following ways.

Format:

Insert <tbname>,<tags> <values> [timestamp]    

Description
Tbname: Data table name
Tags: the tag field of the table
Values: The Value field of the table
Timestamp: The timestamp of the current data (optional, the system will be added if not provided)

Examples are as follows:

> Use testdb; Using database TestDB> Insert students,stuid=s123 score=> show Measurements;name: Measurementsname----students
    • Delete a table

Format:

Drop Measurement  <tbname>  

Description
Tbname: Data table name

Examples are as follows:

> Use testdb; Using database TestDB> Drop measurement students; > show measurements; >
Data manipulation
    • Add to

Format:

Description
Tbname: Data table name
Tags: the tag field of the table
Values: The Value field of the table
Timestamp: The timestamp of the current data (optional, the system will be added if not provided)

Examples are as follows:

> Insert students,stuid=s123 score=> Insert students,stuid=s123 score=   1488821368327436809Select * from studentsname:studentstime                    score   Stuid----                    -----   -----1488821368327436809           s123 1488821404414227498      -      S123
    • Inquire

Format:

Select <fields> from <tbname> [Into_clause] [where_clause]                        [Group_by_clause] [order_by _clause] [limit_clause] [                        offset_clause] [slimit_clause] [soffset_clause]     

Description
Fields: To query the field, the query can all be used *
Tbname: Data table name
Into_clause:select. into (optional)
Where_clause:where condition field (optional)
Group_by_clause:group by correlation (optional)
Order_by_clause:order by correlation (optional)
Limit_clause:limit Related (optional)
Offset_clause:offset Related (optional)
Slimit_clause:slimit Related (optional)
Soffset_clause:soffset Related (optional)

Examples are as follows:

>Use TestDB; Using database TestDB>Show Measurements;name:measurementsname----Students>Select*From studentsname:students Timescore Stuid----                    -----   -----1488821368327436809      thes1231488821404414227498      -s1231488822192864587535      thes1231488822196951305763      thes123>Select* from students where score > -; name:students Timescore Stuid----                    -----   -----1488821368327436809      thes1231488821404414227498      -s123>Select* from students where score > -Limit1; name:students Timescore Stuid----                    -----   -----1488821368327436809      thes123>
    • Update

tags and timestamp the same time data will perform overwrite operations, equivalent to INFLUXDB update operations.

Examples are as follows:

> Insert students,stuid=s123 score= the>Select*From studentsname:students Timescore Stuid----                    -----   -----1488822338410283027      thes123> Insert students,stuid=s123 score= About 1488822338410283027>Select*From studentsname:students Timescore Stuid----                    -----   -----1488822338410283027      Abouts123>
    • Delete

Format:

Delete from <tbname> [Where_clause]   

Description
Tbname: Table Name
Where_clause:where Conditions (optional)

Delete all data:

> Delete from students; Select * from students; >

Delete data for the specified condition:

>Select*From students;name:students Timescore Stuid----                    -----   -----1488820352594964019      thes1231488820356463338534      -s123> Delete from students where stuid='s123'and Time=1488820352594964019;>Select*From students;name:students Timescore Stuid----                    -----   -----1488820356463338534      -s123>
Other
    • The console executes a single query

Format:

' <query> '

Similar to the MYSQL-E functionality, the sample code is as follows:

' Show Databases ' name:databasesname----~]#
    • Specifies that the query results are output in CSV or JSON format

Format:

Influx-format=[format]     

Description

Format: Start formatting, support Column,csv,json three formats, default to column

Examples are as follows:

[Email protected] ~]# influx-format=csvvisit https://enterprise.influxdata.com to register for updates, InfluxDB Server management, and monitoring.Connected to http://localhost:8086 version 1.1.0InfluxDB Shell version:1.1.0>Show Databases;name,namedatabases,_internaldatabases,testdb>Exit[[email protected]~]# influx-format=jsonvisit https://enterprise.influxdata.com to register for updates, InfluxDB Server management, and monitoring.Connected to http://localhost:8086 version 1.1.0InfluxDB Shell version:1.1.0>show databases; {"Results":[{"Series":[{"name":"databases","Columns":["name"],"Values":[["_internal"],["TestDB"]]}]}]}>Exit[[email protected]~]# Influx-format=json-prettyvisit https://enterprise.influxdata.com to register for updates, InfluxDB Server management, and monitoring.Connected to http://localhost:8086 version 1.1.0InfluxDB Shell version:1.1.0>show databases; {    "Results": [        {            "Series": [                {                    "name":"databases",                    "Columns": [                        "name"                    ],                    "Values": [                        [                            "_internal"                        ],                        [                            "TestDB"                        ]                    ]                }            ]        }    ]}>

All right, that's it, I hope it helps you.

This article GitHub address:

https://github.com/mike-zhang/mikeBlogEssays/blob/master/2017/20170307_ Use the influx console tool to operate INFLUXDB.MD

Welcome to Supplement

Use the influx console tool to operate the INFLUXDB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.