Manage your data using InfluxQL
Use the following data management commands to write and delete data with InfluxQL:
Write data with INSERT
The INSERT
statement writes line protocol
to a database and retention policy.
Syntax
INSERT [INTO <database>[.<retention-policy>]] <line-protocol>
- The
INTO
clause is optional. If the command does not includeINTO
, you must specify the database withUSE <database_name>
when using the InfluxQL shell or with thedb
query string parameter in the InfluxDB 1.x compatibility API request.
Examples
- Insert data into the a specific database and retention policy
- Insert data into the a the default retention policy of a database
- Insert data into the currently used database
Insert data into the a specific database and retention policy
INSERT INTO mydb.myrp example-m,tag1=value1 field1=1i 1640995200000000000
Insert data into the a the default retention policy of a database
INSERT INTO mydb example-m,tag1=value1 field1=1i 1640995200000000000
Insert data into the currently used database
The following example uses the InfluxQL shell.
> USE mydb
> INSERT example-m,tag1=value1 field1=1i 1640995200000000000
Delete series with DELETE
The DELETE
statement deletes all points from a series in a database.
Syntax
DELETE FROM <measurement_name> WHERE [<tag_key>='<tag_value>'] | [<time interval>]
You must include either the FROM
clause, the WHERE
clause, or both.
DELETE
supports regular expressions in theFROM
clause when specifying measurement names and in theWHERE
clause when specifying tag values.DELETE
does not support fields in theWHERE
clause.
Examples
- Delete all measurement data
- Delete data in a measurement that has a specific tag value
- Delete data before or after specified time
Delete all measurement data
Delete all data associated with the measurement h2o_feet
:
DELETE FROM "h2o_feet"
Delete data in a measurement that has a specific tag value
Delete all data associated with the measurement h2o_quality
and where the tag randtag
equals 3
:
DELETE FROM "h2o_quality" WHERE "randtag" = '3'
Delete data before or after specified time
Delete all data in the database that occur before January 01, 2020:
DELETE WHERE time < '2020-01-01'
A successful DELETE
query returns an empty result.
If you need to delete points in the future, you must specify the future time period because DELETE SERIES
runs for time < now()
by default.
Delete future points:
DELETE FROM device_data WHERE "device" = 'sensor1" and time > now() and < '2024-01-14T01:00:00Z'
Delete points in the future within a specified time range:
DELETE FROM device_data WHERE "device" = 'sensor15" and time >= '2024-01-01T12:00:00Z' and <= '2025-06-30T11:59:00Z'
Delete measurements with DROP MEASUREMENT
The DROP MEASUREMENT
statement deletes all data and series from the specified measurement and deletes the measurement from the index.
Syntax
DROP MEASUREMENT <measurement_name>
Example
Delete the measurement h2o_feet
:
DROP MEASUREMENT "h2o_feet"
A successful DROP MEASUREMENT
query returns an empty result.
The DROP MEASUREMENT command is very resource intensive. We do not recommend this command for bulk data deletion. Use the DELETE FROM command instead, which is less resource intensive.
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.