SnowConvert AI - Redshift - CREATE TABLE¶
Create Table Syntax Grammar.
描述¶
在当前数据库中创建新表。您可以定义列的列表,每列都包含不同类型的数据。该表的所有者是 CREATE TABLE 命令的发布者。
有关更多信息,请参阅 CREATE TABLE (https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html) 文档。
Grammar Syntax ¶
BACKUP¶
描述¶
使 Amazon Redshift 能够自动调整表中所有列的编码类型以优化查询性能。在 Snowflake 中,如其他数据库中所示的“BACKUP”概念并不直接适用。Snowflake 通过其 Time Travel 和故障安全等内置功能自动处理数据备份和恢复,无需手动备份操作。因此,在转换过程中删除了语句 BACKUP
See the Redshift data distribution documentation (https://docs.aws.amazon.com/redshift/latest/dg/t_Distributing_data.html) for this syntax.
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
IF NOT EXISTS¶
描述¶
在 Amazon Redshift 中,IF NOT EXISTS 用于表创建命令,以避免在表已经存在时出错。如果添加了此语法,则可确保仅在表不存在时才创建该表,从而防止 SQL 脚本中出现重复和错误。
See the Redshift CREATE TABLE documentation (https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html) for this syntax.
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
相关的 EWIs¶
没有已知问题。
LOCAL¶
描述¶
在 Amazon Redshift 中,LOCAL TEMPORARY 或 TEMP 用于创建仅在会话期间存在的临时表。这些表是特定于会话的,会在会话结束时自动删除。它们可用于在不影响永久数据库架构的情况下存储中间结果或工作数据。
See the Redshift CREATE TABLE documentation (https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html) for this syntax.
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
相关的 EWIs¶
没有已知问题。
DISTKEY¶
描述¶
在 Amazon Redshift 中,DISTKEY 用于在集群节点之间分配数据以优化查询性能。但是,Snowflake 无需明确的分布键即可自动处理数据分布和存储。由于架构和数据管理方法的差异,Snowflake 没有与 Redshift 的 DISTKEY 直接等效的项。
See the Redshift data distribution documentation (https://docs.aws.amazon.com/redshift/latest/dg/t_Distributing_data.html) for this syntax.
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
相关的 EWIs¶
SSC-FDM-RS0001: Data storage option is not supported in Snowflake. Data distribution is automatically handled by Snowflake.
DISTSTYLE¶
描述¶
该关键字用于定义整表的数据分布方式。
See the Redshift data distribution documentation (https://docs.aws.amazon.com/redshift/latest/dg/t_Distributing_data.html) for this syntax.
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
相关的 EWIs¶
SSC-FDM-RS0001: Data storage option is not supported in Snowflake. Data distribution is automatically handled by Snowflake.
ENCODE¶
描述¶
在 Snowflake 中,不必定义 ENCODE,因为它会自动处理数据压缩,这与 Redshift 不同,后者需要手动编码设置。因此,在迁移过程中删除了 ENCODE 语句。
See the Redshift CREATE TABLE documentation (https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html) for this syntax.
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
相关的 EWIs¶
There are no known issues.
SORTKEY¶
描述¶
该关键字用于指定该列是表的排序键。在 Snowflake 中,SORTKEY 可以从 Redshift 迁移到 CLUSTER BY,因为两者都优化了数据存储以提高查询性能。CLUSTER BY 在 Snowflake 中组织指定列上的数据,类似于 SORTKEY 在 Redshift 中对数据进行排序的方式。
See the Redshift data distribution documentation (https://docs.aws.amazon.com/redshift/latest/dg/t_Distributing_data.html) for this syntax.
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
相关的 EWIs¶
SSC-FDM-RS0001: Data storage option is not supported in Snowflake. Data distribution is automatically handled by Snowflake.
SSC-FDM-RS0002: The performance of CLUSTER BY in Snowflake may vary compared to the performance of SORTKEY in Redshift.
FOREIGN KEY¶
描述¶
指定外键约束的约束条件,它要求新表的一组(一个或多个)列包含的值必须与引用表的某行的引用列(一列或多列)中的值相匹配。
See the Redshift CREATE TABLE documentation (https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html) for this syntax.
警告
外键的转换将在未来实现。
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
相关的 EWIs¶
SSC-FDM-RSOOO3:未来将支持外键转换。
PRIMARY KEY¶
描述¶
指定表的一列或多列只能包含唯一的非空值
See the Redshift CREATE TABLE documentation (https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html) for this syntax.
备注
在 Snowflake 中,唯一键、主键和外键用于文档,不强制约束条件或唯一性。它们有助于描述表关系,但不影响数据完整性或性能。
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
相关的 EWIs¶
没有已知问题。
UNIQUE¶
描述¶
指定表的一组(一个或多个)列只能包含唯一值。
See the Redshift CREATE TABLE documentation (https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html) for this syntax.
备注
在 Snowflake 中,唯一键、主键和外键用于文档,不强制约束条件或唯一性。它们有助于描述表关系,但不影响数据完整性或性能。
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
相关的 EWIs¶
没有已知问题。
NOT NULL | NULL¶
描述¶
NOT NULL 指定该列不允许包含 null 值。而 NULL(默认值)则指定该列可以接受 null 值。
See the Redshift CREATE TABLE documentation (https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html) for this syntax.
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
相关的 EWIs¶
没有已知问题。
REFERENCES¶
描述¶
指定外键约束,这意味着该列必须仅包含与引用表某行的引用列中的值相匹配的值
See the Redshift CREATE TABLE documentation (https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html) for this syntax.
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
相关的 EWIs¶
没有已知问题。
UNIQUE | PRIMARY KEY¶
描述¶
指定该列只能包含唯一值。在 Snowflake 中,UNIQUE 和 PRIMARY KEY 都用于记录和结构化数据,但从某种意义上说,它们不具有您在存储级别强制执行这些限制的其他数据库系统中所期望的活跃数据验证功能。
See the Redshift CREATE TABLE documentation (https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html) for this syntax.
备注
在 Snowflake 中,唯一键、主键和外键用于文档,不强制约束条件或唯一性。它们有助于描述表关系,但不影响数据完整性或性能。
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
相关的 EWIs¶
没有已知问题。
COLLATE¶
描述¶
指定列上的字符串搜索或比较是 CASE_SENSITIVE 还是 CASE_INSENSITIVE。
See the Redshift CREATE TABLE documentation (https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html) for this syntax.
备注
默认排序规则语言是英语。如果您的数据库使用的是其他语言,请更新“en-”前缀以匹配您的数据库语言。有关更多信息,请参阅此 链接。
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
已知问题¶
There are no known issues.
DEFAULT¶
描述¶
为列分配默认数据值。
See the Redshift CREATE TABLE DEFAULT clause documentation (https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html#create-table-default) for this syntax.
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
相关的 EWIs¶
没有已知问题。
DISTKEY¶
描述¶
在 Amazon Redshift 中,DISTKEY 用于在集群节点之间分配数据以优化查询性能。但是,Snowflake 无需明确的分布键即可自动处理数据分布和存储。由于架构和数据管理方法的差异,Snowflake 没有与 Redshift 的 DISTKEY 直接等效的项。因此,在转换过程中删除了语句 DISTKEY
See the Redshift data distribution documentation (https://docs.aws.amazon.com/redshift/latest/dg/t_Distributing_data.html) for this syntax.
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
相关的 EWIs¶
没有已知问题。
ENCODE¶
描述¶
列的压缩编码。在 Snowflake 中,不必定义 ENCODE,因为它会自动处理数据压缩,这与 Redshift 不同,后者需要手动编码设置。因此,在迁移过程中删除了 ENCODE 语句。
See the Redshift CREATE TABLE ENCODE clause documentation (https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html#create-table-encode) for this syntax.
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
相关的 EWIs¶
没有已知问题。
GENERATED BY DEFAULT AS IDENTITY¶
描述¶
指定列为默认 IDENTITY 列,并允许您自动为该列分配唯一值。
See the Redshift IDENTITY column documentation (https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html#identity-generated-bydefault-clause) for this syntax.
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
相关的 EWIs¶
没有已知问题。
IDENTITY¶
描述¶
指定列为 IDENTITY 列的子句。(RedShift SQL 语言参考“Identity” (https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html#identity-clause))。
语法¶
示例源模式¶
输入代码:¶
Redshift¶
Results¶
DOC |
ID1 |
ID2 |
ID3 |
ID4 |
|---|---|---|---|---|
1 |
1 |
5 |
1 |
1 |
2 |
2 |
8 |
3 |
7 |
3 |
3 |
11 |
5 |
13 |
输出代码:¶
Snowflake¶
Results¶
DOC |
ID1 |
ID2 |
ID3 |
ID4 |
|---|---|---|---|---|
1 |
1 |
5 |
1 |
1 |
2 |
2 |
8 |
3 |
7 |
3 |
3 |
11 |
5 |
13 |
已知问题 ¶
未发现任何问题。
相关的 EWIs¶
没有已知问题。
SORTKEY¶
描述¶
该关键字用于指定该列是表的排序键。在 Snowflake 中,SORTKEY 可以从 Redshift 迁移到 CLUSTER BY,因为两者都优化了数据存储以提高查询性能。CLUSTER BY 在 Snowflake 中组织指定列上的数据,类似于 SORTKEY 在 Redshift 中对数据进行排序的方式。
See the Redshift data sorting documentation (https://docs.aws.amazon.com/redshift/latest/dg/t_Sorting_data.html) for this syntax.
语法¶
示例源模式¶
输入代码:¶
Redshift¶
输出代码:¶
Snowflake¶
已知问题¶
SSC-FDM-RS0002: The performance of CLUSTER BY in Snowflake may vary compared to the performance of SORTKEY in Redshift.