Skip to main content

Truncate

This statement is used to clear the data of a specified table or partition in Doris

Syntax

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

  1. Truncate the table tbl under example_db.
TRUNCATE TABLE example_db.tbl;
  1. Truncate partitions p1 and p2 of table tbl.
TRUNCATE TABLE tbl PARTITION(p1, p2);