All Products
Search
Document Center

Database management

Last Updated: May 19, 2022

TSDB for InfluxDB® provides a set of database management commands. The topic describes how to execute the DELETE statement.

You can use the TSDB for InfluxDB® CLI or send an HTTP API request to execute the DELETE statement. This topic provides examples on how to execute the DELETE statement. The TSDB for InfluxDB® CLI is used in these examples. For information about HTTP API requests, see HTTP API.

Data management

Execute the DELETE statement to delete points from a series

The DELETE statement deletes all points from a series in a database and allows you to specify a time interval in the WHERE clause. The DELETE statement does not delete the series from the corresponding index.

The DELETE statement uses the following syntax. The FROM or WHERE clause is required. You can also use the FROM and WHERE clauses together.

DELETE FROM <measurement_name> WHERE [<tag_key>='<tag_value>'] | [<time interval>]

The following statement deletes all points in the h2o_feet measurement.

> DELETE FROM "h2o_feet"

The following statement deletes all points in the h2o_quality measurement where the tag value of the randtag tag key is 3.

> DELETE FROM "h2o_quality" WHERE "randtag" = '3'

The following statement deletes all points that were generated before January 1, 2016 from the database.

> DELETE WHERE time < '2016-01-01'

If the DELETE statement is executed as expected, an empty result is returned.

Before you execute the DELETE statement, take note of the following items:

  • If you specify a measurement name, you can use a regular expression in the FROM clause of the DELETE statement. If you specify a tag value, you can use a regular expression in the WHERE clause of the DELETE statement.

  • A field cannot be specified in the WHERE clause of the DELETE statement.

  • By default, the DELETE statement deletes data generated during the time period specified by time < now(). Therefore, if you need to delete points that are generated during a time period later than the point in time returned by now(), you must specify the time period.

InfluxDB® is a trademark registered by InfluxData, which is not affiliated with, and does not endorse, TSDB for InfluxDB®.