There are no update statements for the InfluxDB that modify data. However, if the data is modified by the InfluxDB, insert statements are still used.

1. Insert Data modification

For more information on insert usage syntax, see the previous post: 190726-Influx Sql series 5: Insert Add Data

Here is just the basic grammar

insert into <retention policy> measurement,tagKey=tagValue fieldKey=fieldValue timestamp
Copy the code

If we want to modify a piece of data, such as modifying an existing field, or adding/deleting fields, we need to specify the timestamp and tag

Here is a simple demonstration of the changes

> select * from add_test where time=1564149327925320596
name: add_test
time                age boy email            name  phone user_id
----                --- --- -----            ----  ----- -------
1564149327925320596         [email protected] YiHui 110   20
> show tag keys from add_test
name: add_test
tagKey
------
name
phone
> insert add_test,name=YiHui,phone=110 user_id=20,email="[email protected]",boy=true,age=18i 1564149327925320596
> select * from add_test where time=1564149327925320596
name: add_test
time                age boy  email            name  phone user_id
----                --- ---  -----            ----  ----- -------
1564149327925320596 18  true [email protected] YiHui 110   20
Copy the code

In the above case, several parameters must be present when we execute an INSERT statement to modify an existing record

  • Time: Specifies the timestamp for the record to change
  • Tag: All tags must be consistent with the data to be modifiedname=YiHui,phone=110

The contents of the field will then incrementally modify the previous data as follows

> insert add_test,name=YiHui,phone=110 boy=true,age=19i 1564149327925320596
> select * from add_test where time=1564149327925320596
name: add_test
time                age boy  email            name  phone user_id
----                --- ---  -----            ----  ----- -------
1564149327925320596 19  true [email protected] YiHui 110   20
Copy the code

With the insert above, I can dynamically add fields, but what if I want to delete fields?

  • Currently availableinfluxdb sqlAn alternative to deleting a field is to delete the original record. And then insert another one

What if you need to modify the tag?

  • As shown in the previous case, modifying records is based on time + tag values to uniquely locate records and then delete them. If you need to modify a tag, yesinsertAdd a point; Consider deleting old data yourself

II. The other

0. Series of blog posts

  • 190726-Influx Sql Series 5: Insert Add Data
  • 190723- Whole ARRAY Sql Series 4: Series/Point/Tag/Field
  • 190721- Whole Sql Series 3: Measurement Tables
  • 190719- Readership RETENTION Policies, Readership Retention Policies, Readership Retention Policies, Readership Retention Policies
  • 190718- Whole Sql Series 1: Database database
  • 190717- Introduction to Installation and READy-to-USE CLI posture
  • 190509-InfluxDb Timestamp is displayed in date format
  • 190506-InfluxDB Configuration modified
  • 190505-Rights management for the InfluxDB
  • 180727- Backup and restore policies for the sequential database InfluxDB
  • Summary of basic concepts of 180726-InfluxDB
  • Installation and Simple use summary of 180725-INFLUxDB-V1.6.0

Refer to the post

  • Docs.influxdata.com/influxdb/v1…
  • Docs.influxdata.com/influxdb/v1…
  • docs.influxdata.com/influxdb/v1.7/tools/shell/#write-data-to-influxdb-with-insert

1. A gray Blog:liuyueyi.github.io/hexblog

A gray personal blog, recording all the study and work in the blog, welcome everyone to go to stroll

2. Statement

As far as the letter is not as good as, has been the content, purely one’s own words, because of the limited personal ability, it is hard to avoid omissions and mistakes, such as finding bugs or better suggestions, welcome criticism and correction, not grudging gratitude

  • Micro Blog address: Small Gray Blog
  • QQ: a gray /3302797840

3. Scan attention

A gray blog