TRUNCATE

Removes all rows from the table. TRUNCATE is equivalent to running a DELETE which removes all the rows from the table but without all the overhead of deleting one row at a time.

Syntax

TRUNCATE [TABLE] tbl_name

Remarks

  • This command must be run on the master aggregator node (see Node Requirements for MemSQL Commands).
  • If there is a long-running query executing at the time a TRUNCATE operation is run the TRUNCATE will block and wait for it to finish. This is the same locking that an ALTER operation does before running.

Example

mysql> TRUNCATE TABLE mytbl;
Query OK, 1 row affected (6.32 sec)

Related Topics

Was this article useful?