CREATE … CLONE 命令:克隆包含混合表的数据库和架构

Attention

This behavior change is in the 2024_08 bundle.

For the current status of the bundle, refer to Bundle History.

Given that hybrid tables have limited support for cloning, note the following behavior when you attempt to clone a database or a schema that contains hybrid tables:

Before the change:

In general, CREATE DATABASE … CLONE and CREATE SCHEMA … CLONE commands silently skip hybrid tables if any exist in the specified database or schema.

CREATE DATABASE …如果命令中没有指定 Time Travel 参数,或者指定了 AT TIMESTAMP 值,则 CLONE 命令将克隆混合表。

例如,以下命令会成功执行,但会跳过混合表:

CREATE SCHEMA dst CLONE src;
CREATE DATABASE dst CLONE src
  BEFORE (STATEMENT => '01b7676a-0002-d908-0000-a99500f6e00e');

以下命令成功执行,并在克隆数据库中包含混合表:

CREATE DATABASE dst CLONE src;
After the change:

CREATE SCHEMA … 如果指定的架构中存在任何混合表,CLONE 命令将返回错误。例如,以下命令会失败:

CREATE SCHEMA dst CLONE src;
392105 (0A000): SQL execution error: Cloning a SCHEMA which contains a HYBRID TABLE is unsupported. To perform the clone while skipping HYBRID TABLES, append the `IGNORE HYBRID TABLES` syntax to your DDL.

The error prompts you to run the command using the IGNORE HYBRID TABLES parameter. When you use this parameter, the command will create the cloned schema but skip any hybrid tables. For example:

CREATE SCHEMA dst CLONE src IGNORE HYBRID TABLES;

CREATEDATABASE …CLONE 命令的行为未指定 Time Travel 参数的命令不会更改。例如,以下命令成功执行,并在克隆的数据库中包含混合表:

CREATE DATABASE dst CLONE src;

CREATE DATABASE … CLONE commands that use Time Travel and specify the time with the STATEMENT parameter return an error if any hybrid tables exist in the specified database. For example, the following command fails:

CREATE DATABASE dst CLONE src
  BEFORE (STATEMENT => '01b7676a-0002-d908-0000-a99500f6e00e');
392106 (0A000): SQL execution error: Time Travel cloning a DATABASE which contains a HYBRID TABLE, when specifying the time via a `STATEMENT` is unsupported. To perform the clone while skipping HYBRID TABLES, append the `IGNORE HYBRID TABLES` syntax to your DDL.

该错误提示您使用 IGNORE HYBRID TABLES 参数。使用此参数时,该命令将创建克隆数据库,但会跳过任何混合表。例如:

CREATE DATABASE dst CLONE src
  BEFORE (STATEMENT => '01b7676a-0002-d908-0000-a99500f6e00e')
  IGNORE HYBRID TABLES;

其他 CREATE DATABASE …CLONE 命令如果指定 Time Travel 参数,并且没有为包含混合表的目标数据库使用 AT TIMESTAMP,则要么返回错误,要么自动跳过混合表:

  • 如果(显式或默认)启用了捆绑包,这些 CREATE DATABASE …CLONE 命令将返回错误。
  • 如果显式禁用捆绑包,这些 CREATE DATABASE …CLONE 命令会自动跳过混合表。

For more information, see Clone databases that contain hybrid tables.

参考:1792