截短

截短 — empties a table

句法

截短 TABLE [schema.]tableName

描述

截短 operates on the table instead of individual rows. Therefore the command 截短 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 删除 privilege on the table in order to invoke 截短 on it. After execution of 截短 TABLE, disk space is not reclaimed immediately. To reclaim new unused disk space, use 诺博德档案馆.

在单个呼叫中使用多个语句时,只能使用Truncate命令,如果它是呼叫中的第一个语句。如果不是,则返回错误。

例如:

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

参数

tableName

要截断的表的名称(可选地模式限定)。

例子

CREATE TABLE tab_truncate (col1 STRING);
 INTO tab_truncate VALUES ('row1'),('row2'),('row3');
选择 * FROM tab_truncate;
 COL1
 -----
 row1
 row2
 row3

截短 TABLE tab_truncate;
选择 * FROM tab_truncate;

/* There are no records selected */