TRUNCATE

Function

TRUNCATE quickly removes all rows from a database table.

It has the same effect as an unqualified DELETE on each table, but it is faster since it does not actually scan the tables. This is most useful on large tables.

Precautions

  • Avoid performing ALTER TABLE, ALTER TABLE PARTITION, DROP PARTITION, and TRUNCATE operations during peak hours to prevent long SQL statements from blocking these operations or SQL services.
  • For more information about development and design specifications, see "GaussDB(DWS) Development and Design Proposal" in the GaussDB(DWS) Developer Guide.

TRUNCATE TABLE

Syntax

TRUNCATE empties a table or set of tables.

1
2
TRUNCATE [ TABLE ] [ ONLY ] {[[database_name.]schema_name.]table_name [ * ]} [, ... ]
    [ CONTINUE IDENTITY ] [ CASCADE | RESTRICT ] ;

Parameter Description

Examples

Clear a partitioned table:

1
TRUNCATE TABLE tpcds.customer_address;