TSDB for InfluxDB® provides a complete set of statements for you to manage databases. This topic describes how to execute the DELETE
statement.
For more information about SHOW
statements, such as SHOW DATABASES
and SHOW RETENTION POLICIES
, see the Schema exploration topic.
The command-line interface (CLI) of TSDB for InfluxDB® is used in the examples that are provided in this topic. You can also use the HTTP API to run commands. To do this, send GET
requests to the /query
endpoint and use the q
parameter in the URL to specify the commands. For more information about the HTTP API, see the “Use the HTTP API to query data” topic.
Data management
Execute the DELETE statement to delete the specified series
You can execute the DELETE
statement to delete all the points of a series in a database. However, this operation does not delete the series from the index. In the WHERE
clause of the DELETE statement, you can specify the time interval based on your business requirements.
The DELETE
statement uses the following syntax. You must include at least one of the following clauses in the DELETE statement: FROM
and WHERE
clauses.
DELETE FROM <measurement_name> WHERE [<tag_key>='<tag_value>'] | [<time interval>]
Delete all the data that is associated with the h2o_feet
measurement.
> DELETE FROM "h2o_feet"
Delete the data where the tag value of the randtag
tag key is 3 in the h2o_quality
measurement.
> DELETE FROM "h2o_quality" WHERE "randtag" = '3'
Delete all the data that is generated before January 1, 2016 in the database.
> DELETE WHERE time < '2016-01-01'
If the DELETE
operation is successful, no result is returned.
Pay attention to the following considerations when you execute the DELETE
statement:
- You can use regular expressions to specify measurement names in the
FROM
clause of theDELETE
statement. You can also use regular expressions to specify tag values in theWHERE
clause of theDELETE
statement. - You cannot specify fields in the
WHERE
clause of theDELETE
statement. - If you need to delete the data that is generated after the time returned by the
now()
function, you must specify the corresponding time period. This is because theDELETE SERIES
statement deletes the data that is generated before the time returned by the now() function (time < now()
) by default.
InfluxDB® is a trademark registered by InfluxData, which is not affiliated with, and does not endorse, TSDB for InfluxDB®.