如何向 AWS Redshift 中的现有表添加排序键 [英] How to add a sort key to an existing table in AWS Redshift

查看:53
本文介绍了如何向 AWS Redshift 中的现有表添加排序键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 AWS Redshift 中,我想向已创建的表添加排序键.是否有任何可以添加列并将其用作排序键的命令?

In AWS Redshift, I want to add a sort key to a table that is already created. Is there any command which can add a column and use it as sort key?

推荐答案

更新:

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.

这篇关于如何向 AWS Redshift 中的现有表添加排序键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆