content/shared/influxdb-v2/query-data/influxql/manage-data.md
Use the following data management commands to write and delete data with InfluxQL:
The INSERT statement writes line protocol
to a database and retention policy.
INSERT [INTO <database>[.<retention-policy>]] <line-protocol>
INTO clause is optional.
If the command does not include INTO, you must specify the
database with USE <database_name> when using the InfluxQL shell
or with the db query string parameter in the
InfluxDB 1.x compatibility API request.INSERT INTO mydb.myrp example-m,tag1=value1 field1=1i 1640995200000000000
INSERT INTO mydb example-m,tag1=value1 field1=1i 1640995200000000000
The following example uses the InfluxQL shell.
> USE mydb
> INSERT example-m,tag1=value1 field1=1i 1640995200000000000
The DELETE statement deletes all points from a series in a database.
DELETE FROM <measurement_name> WHERE [<tag_key>='<tag_value>'] | [<time interval>]
You must include either the FROM clause, the WHERE clause, or both.
{{% note %}}
DELETE supports regular expressions
in the FROM clause when specifying measurement names and in the WHERE clause
when specifying tag values.DELETE does not support fields in the WHERE clause.
{{% /note %}}Delete all data associated with the measurement h2o_feet:
DELETE FROM "h2o_feet"
Delete all data associated with the measurement h2o_quality and where the tag randtag equals 3:
DELETE FROM "h2o_quality" WHERE "randtag" = '3'
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'
The DROP MEASUREMENT statement deletes all data and series from the specified measurement and deletes the measurement from the index.
DROP MEASUREMENT <measurement_name>
Delete the measurement h2o_feet:
DROP MEASUREMENT "h2o_feet"
A successful DROP MEASUREMENT query returns an empty result.
{{% warn %}} 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. {{% /warn %}}