TRUNCATE
TRUNCATE
— empties a table
Description
TRUNCATE operates on the table instead of individual rows. Therefore the command TRUNCATE TABLE
removes all rows from a table without logging individual row deletions. It is more efficient than using DELETE without a WHERE clause for large tables.
The user must have the DELETE
privilege on the table in order to invoke TRUNCATE
on it. After execution of TRUNCATE TABLE
, disk space is not reclaimed immediately. To reclaim new unused disk space, use NuoDB Archive.
When using multiple statements in a single call, the TRUNCATE command can only be used if it is the first statement in the call. If it is not, an error is returned. |
For example:
SQL> create table if not exists a (a int); truncate table a;
syntax error on line 1
create table if not exists a (a int); truncate table a;
^
expected = got TABLE