This content has moved to https://go.treasuredata.com/docs
This article summarizes options for deleting row level data from an Arm Treasure Data table. The current best practice is to use the Presto DELETE command. The older Partial Delete method is documented for customers who are still using it but it is not recommended.
- Basic knowledge of Treasure Data, including the TD Toolbelt
- Understanding of Presto or Hive
As you use the procedures in this article, refer to the following articles:
- Presto DELETE Statement Syntax and also Presto DELETE limitations.
- Partial Delete: Efficient for small tables because it reloads the entire table
- Partial Delete based on TIME Column: Efficient for huge tables. You take a superset of rows, which includes rows to be deleted and filtered based on the
Using Presto DELETE Statements
Presto Delete enables you to issues DELETE statement queries against any table in Treasure Data.
- Use the following syntax to isolate the row you want to delete and delete it:
DELETE FROM table_name [ WHERE condition ]
DELETE FROM emp WHERE name = 'beekeeper1'
Arm TD previously offered and still supports a technique known as "partial delete" that deleted all rows in a specific time range by dropping the partitions covering that time range. This technique is no longer recommended because it is more complex and more likely to lead to user error. Customers should use Presto DELETE instead.
One way to use this feature to delete a subset of rows was to:
1. Extract rows in the desired time range into a temporary table using:
saved_rows_tbl AS SELECT
_condition_ = 0
AND td_time_range(. . .)
2. Delete the whole time range using the partial delete command in TD Toolbelt:
td table:partial_delete example_db source_table --from _start_time_ --to _end_time_
See https://support.treasuredata.com/hc/en-us/articles/360001262027-Partial-Deletion-Syntax for more syntax details.
3. Re-insert the saved rows into the table
4. Delete the saved_rows_table once you have confirmed that the result of the INSERT INTO has restored the desired rows.