Truncate
This statement is used to clear the data of a specified table or partition in Doris
Syntax
1. TRUNCATE TABLE [db.]tbl[ PARTITION(p1, p2, ...)];
- This statement only clears the data within a table or partition but preserves the table or partition itself.
- Unlike DELETE, this statement can only clear the specified table or partition as a whole and cannot be added with filter conditions.
- Unlike DELETE, truncating data will not affect query performance.
- The data deleted by this operation is not recoverable.
- When using this command, the table status must be NORMAL, which means that tables undergoing SCHEMA CHANGE can not be truncated.
- This command may cause ongoing imports to fail.
Example
- Truncate the table
tblunderexample_db.
1. TRUNCATE TABLE example_db.tbl;
- Truncate partitions
p1andp2of tabletbl.
1. TRUNCATE TABLE tbl PARTITION(p1, p2);
