Clears a table.
Syntax
TRUNCATE TABLE name [DROP STORAGE]
Description
The TRUNCATE
command removes all rows from a table. This command has the same effect as an unqualified
DELETE
command. However, the TRUNCATE command is faster because it does not scan the table.
This is most useful for large tables.
The DROP STORAGE
clause is used for compatibility, but is ignored.
Parameters
Parameter | Description |
---|
Parameter | Description |
---|---|
name | The name of the table to be truncated. The name can be schema-qualified. |
Notes
If other tables have foreign-key references to the table to be truncated, you cannot
use the TRUNCATE
command. This is because table scans are required for validity check.
The TRUNCATE
command does not run user-defined ON
DELETE
triggers for the table even if you have configured such triggers.
Examples
Run the following command to truncate the bigtable table:
TRUNCATE TABLE bigtable;