TRUNCATE

Function

Quickly removes all rows from a database table.

TRUNCATE 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

Exercise caution when running the TRUNCATE TABLE statement. Before running this statement, ensure that the table data can be deleted. After you run the TRUNCATE TABLE statement to delete table data, the data cannot be restored.

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;