H2 Database 简明教程

H2 Database - Truncate

TRUNCATE 是一条用于从表中删除数据的命令。与没有 WHERE 子句的 DELETE FROM 不同,此命令无法回滚。此命令会提交此连接中的打开事务。

TRUNCATE is a command used to delete the data from the table. Unlike DELETE FROM without WHERE clause, this command cannot be rolled back. This command commits an open transaction in this connection.

Syntax

以下是 truncate 命令的通用语法。

Following is the generic syntax of the truncate command.

TRUNCATE TABLE tableName

Example

在此示例中,我们将使用以下查询截断名为 test 的表。

In this example, we will truncate a table named test using the following query.

TRUNCATE TABLE test;

以上查询将产生以下输出。

The above query produces the following output.

(6) row (s) effected