TRUNCATE-TABLE
TRUNCATE-TABLEβ
Nameβ
TRUNCATE TABLE
Descriptionβ
This statement is used to clear the data of the specified table and partition grammar:
TRUNCATE TABLE [db.]tbl[ PARTITION(p1, p2, ...)];
illustrate:
- The statement clears the data, but leaves the table or partition.
- Unlike DELETE, this statement can only clear the specified table or partition as a whole, and cannot add filter conditions.
- Unlike DELETE, using this method to clear data will not affect query performance.
- The data deleted by this operation cannot be recovered.
- When using this command, the table status needs to be NORMAL, that is, operations such as SCHEMA CHANGE are not allowed.
Exampleβ
Clear the table tbl under example_db
TRUNCATE TABLE example_db.tbl;
Empty p1 and p2 partitions of table tbl
TRUNCATE TABLE tbl PARTITION(p1, p2);
Keywordsβ
TRUNCATE, TABLE