TRUNCATE TABLE

Documentation

VoltDB Home » Documentation » Using VoltDB

TRUNCATE TABLE

TRUNCATE TABLE — Deletes all records from the specified table.

Synopsis

TRUNCATE TABLE table-name

Description

The TRUNCATE TABLE statement deletes all of the records from the specified table. TRUNCATE TABLE is the same as the statement DELETE FROM {table-name} with no selection clause. These statements contain optimizations to increase performance and reduce memory usage over an equivalent DELETE statement containing a WHERE selection clause.

The following behavior is important to remember when using the TRUNCATE TABLE statement in VoltDB:

  • Executing a TRUNCATE TABLE query on a partitioned table within a single-partitioned stored procedure will only delete the records within the current partition. Records in other partitions will be unaffected.

  • You cannot execute a TRUNCATE TABLE query on a replicated table from within a single-partition stored procedure. To truncate a replicated table you must execute the query within a multi-partition stored procedure or as an ad hoc query.

Examples

The following example removes all data from the CURRENT_STANDINGS table:

TRUNCATE TABLE Current_standings;
>