2. Delete from¶
2.1. Synopsis¶
DELETE FROM { <table_name> | <find_expression> } [, ... ]
IN { RANGE <range_spec> | '[' RANGE <range_spec> [, ...] ']' }
[ WITH DAYS IN ( <day>, <day> ) ]
[ WITH TIME IN ( <time>, <time> ) ]
range_spec ::=
( <timestamp>, <timestamp> )
( <timestamp>, <time_offset> )
find_expression ::=
FIND ( { <tag_expression> | NOT <tag_expression> } [ AND ... ] )
tag_expression ::=
TAG = 'tag_name'
2.2. Description¶
DELETE FROM
removes rows from one or more tables in a specified range.
2.3. Parameters¶
table_name
The name of the table to retrieve rows from.
find_expression
When your tables are tagged, you can use inline key/value lookups to perform your query over multiple tables. To match all tables that have the tag “stocks”, you can use
FIND(tag='stocks' AND type=ts)
.timestamp
An absolute timestamp. This can be either a date or a date + time. Supports precision for days, seconds or nanoseconds. For more information, please refer to the documentation for timestamps.
time_offset
A relative offset, can only be used in combination with an
absolute_timestamp
. For more information, please refer to the documentation for timestamps.day
A weekday. Can be one of
mon
,tue
,wed
,thu
,fri
,sat
orsun
. When defining a subrange usingWITH DAYS IN
, is both left and right inclusive:WITH DAYS IN (mon, tue)
will match both Monday and Tuesday.time
Time of day, having a precision of either minutes, seconds or nanoseconds. When defining a subrange using
WITH TIME IN
, is left inclusive and right exclusive:WITH TIME IN (09:22:00, 09:22:01)
will not match a row whose time is exactly09:22:01
AM.
2.4. Examples¶
Delete everything from the year 2017 in table example:
DELETE FROM example in range(2017, 2018)
Delete everything from the year 2017 in all tables tagged with ‘nyse’:
DELETE FROM FIND(tag='nyse') in range(2017, 2018)
Delete everything from the last week in all tables tagged with ‘nyse’:
DELETE FROM FIND(tag='nyse') in range(now, -1w)