amazon-redshift - 如何在AWS Redshift中向现有表添加排序键

标签 amazon-redshift

在AWS 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-changing-table-sort-keys-dynamically/

目前,我认为这是不可能的(希望将来会改变)。过去,当我遇到这种情况时,我创建了一个新表并将数据从旧表复制到该表中。

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

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.

You cannot add a column that is the distribution key (DISTKEY) or a sort key (SORTKEY) of the table.

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

UNIQUE

PRIMARY KEY

REFERENCES (foreign key)

IDENTITY

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.

关于amazon-redshift - 如何在AWS Redshift中向现有表添加排序键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17884203/

相关文章:

sql - 优化 PostgreSql 查询以获取找到的记录总数和基于多个 group by 的分页所需的有限行数

docker - 从 Go api 连接到 Redshift 时出现 SSL 错误

postgresql - 查询以在亚马逊 Redshift 中获取从给定日期到 48 小时的数据

amazon-web-services - 如何在 Redshift 中创建自定义聚合 UDF 函数?

amazon-web-services - 如何在redshift中找到数据库、模式、表的大小

binary - 计算 Redshift 列中每个位位置中 '1' 值的数量

amazon-redshift - 我们可以通过linux shell脚本无密码连接amazon redshift吗?

sql - 从 Redshift 中的表中获取缺失的日期

mysql - 如果同步到 Redshift/BigQuery,来自 MySQL 数据库的 bin 日志复制是否会保持唯一约束?

sql - 对某些用户隐藏 Amazon Redshift 集群中的数据库