Data deletion in IoTDB can be achieved using the DELETE statement. You can specify filters based on tags and time to delete specific subsets of data.
DELETE FROM <TABLE_NAME> [WHERE_CLAUSE]? WHERE_CLAUSE: WHERE DELETE_CONDITION DELETE_CONDITION: SINGLE_CONDITION | DELETE_CONDITION AND DELETE_CONDITION | DELETE_CONDITION OR DELETE_CONDITION SINGLE_CODITION: TIME_CONDITION | ID_CONDITION TIME_CONDITION: time TIME_OPERATOR LONG_LITERAL TIME_OPERATOR: < | > | <= | >= | = ID_CONDITION: identifier = STRING_LITERAL
Note:
DELETE_CONDITION can include single conditions or be a combination of conditions (logical operators like AND and OR are used). Currently, only time conditions and tag conditions are supported.<, >, etc.).The Example Data pagepage provides SQL statements to construct table schemas and insert data. By downloading and executing these statements in the IoTDB CLI, you can import the data into IoTDB. This data can be used to test and run the example SQL queries included in this documentation, allowing you to reproduce the described results.
# Whole table deletion DELETE FROM table1
# Single time interval deletion DELETE FROM table1 WHERE time <= 2024-11-29 00:00:00 # Multi time interval deletion DELETE FROM table1 WHERE time >= 2024-11-27 00:00:00 and time <= 2024-11-29 00:00:00
# Device-specific deletion # Identifier conditions only support the '=' operator DELETE FROM table1 WHERE device_id='101' and model_id = 'B' # Device-specific deletion with time interval DELETE FROM table1 WHERE time >= 2024-11-27 16:39:00 and time <= 2024-11-29 16:42:00 AND device_id='101' and model_id = 'B' # Device-type-specific deletion DELETE FROM table1 WHERE model_id = 'B'
The device deletion statement supports deleting all devices and their related data in the table.
DELETE DEVICES FROM tableName=qualifiedName (WHERE booleanExpression)?
Notes:
WHERE clause supports only equality filters on tags. Conditions can be combined using AND and OR operators.DELETE DEVICES statement.DELETE DEVICES FROM table1 WHERE device_id = '101'