且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何向 AWS Redshift 中的现有表添加排序键

更新时间:2023-12-06 16:02:34

更新:

Amazon Redshift 现在允许用户添加和更改现有 Redshift 表的排序键,而无需重新创建表.新功能简化了用户在 Redshift 中维护***排序顺序的体验,以便随着查询模式的发展实现高性能,并且不会中断对表的访问.

Amazon Redshift now enables users to add and change sort keys of existing Redshift tables without having to re-create the table. The new capability simplifies user experience in maintaining the optimal sort order in Redshift to achieve high performance as their query patterns evolve and do it without interrupting the access to the tables.

来源:https://aws.amazon.com/about-aws/whats-new/2019/11/amazon-redshift-supports-changed-table-sort-keys-dynamically/

目前我认为这是不可能的(希望将来会改变).以前遇到这种情况,我新建了一张表,把旧表的数据复制进去.

At the moment I think its not possible (hopefully that will change in the future). In the past when I ran into this kind of situation I created a new table and copied the data from the old one into it.

来自 http://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html:

添加 [ COLUMN ] 列名将具有指定名称的列添加到表中.您只能在每个 ALTER TABLE 语句中添加一列.

ADD [ COLUMN ] column_name Adds a column with the specified name to the table. You can add only one column in each ALTER TABLE statement.

不能添加作为表的分布键 (DISTKEY) 或排序键 (SORTKEY) 的列.

您不能使用 ALTER TABLE ADD COLUMN 命令修改以下表和列属性:

You cannot use an ALTER TABLE ADD COLUMN command to modify the following table and column attributes:

独一无二

主键

参考(外键)

身份

最大列名长度为 127 个字符;较长的名称被截断为 127 个字符.您可以在单个表中定义的最大列数为 1,600.

The maximum column name length is 127 characters; longer names are truncated to 127 characters. The maximum number of columns you can define in a single table is 1,600.