VeloDB Cloud
SQL Manual
Statments
Data-Definition-Statements
Drop
TRUNCATE-TABLE

TRUNCATE-TABLE

Name

TRUNCATE TABLE

Description

This statement is used to clear the data of the specified table and partition

Syntax:

TRUNCATE TABLE [db.]tbl[ PARTITION(p1, p2, ...)];

Note:

  • The statement clears the data, but retains 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, please make sure that the table status is NORMAL and not under operations such as SCHEMA CHANGE.

Example

  1. Clear the table tbl under example_db

    TRUNCATE TABLE example_db.tbl;
  2. Empty p1 and p2 partitions of table tbl

    TRUNCATE TABLE tbl PARTITION(p1, p2);

Keywords

 TRUNCATE, TABLE

Best Practice