如何就地更改红移列编码?
How to alter redshift column encoding in place?
有没有办法在原始 table 上 add/alter table 列编码,而无需创建新的 table 和 select 旧 table 到新的 table ?
不,不支持。
来自documentation,您有以下选择:
- 在创建 table
时手动将压缩类型或编码应用于 table 中的列
- 使用 COPY 命令自动分析和应用压缩(在空 table 上)
- 使用 ALTER TABLE 命令将列添加到 table 时指定列的编码
来自同一文档,
You cannot change the compression encoding for a column after the table is created.
科坦说得对。 AWS 确实提供了一个实用程序,https://github.com/awslabs/amazon-redshift-utils/tree/master/src/ColumnEncodingUtility,可以为您处理它。
您真的不必使用新编码创建并行 table。您可以通过添加具有所需压缩的新列来更改现有 table,使用旧列中的值更新新列,最后删除旧列。
是 - 自 2020 年 10 月 20 日起,这是一个受支持的选项,请参阅 AWS 文档:
ALTER TABLE table_name
{
| ALTER COLUMN column_name ENCODE new_encode_type
https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html
有没有办法在原始 table 上 add/alter table 列编码,而无需创建新的 table 和 select 旧 table 到新的 table ?
不,不支持。
来自documentation,您有以下选择:
- 在创建 table 时手动将压缩类型或编码应用于 table 中的列
- 使用 COPY 命令自动分析和应用压缩(在空 table 上)
- 使用 ALTER TABLE 命令将列添加到 table 时指定列的编码
来自同一文档,
You cannot change the compression encoding for a column after the table is created.
科坦说得对。 AWS 确实提供了一个实用程序,https://github.com/awslabs/amazon-redshift-utils/tree/master/src/ColumnEncodingUtility,可以为您处理它。
您真的不必使用新编码创建并行 table。您可以通过添加具有所需压缩的新列来更改现有 table,使用旧列中的值更新新列,最后删除旧列。
是 - 自 2020 年 10 月 20 日起,这是一个受支持的选项,请参阅 AWS 文档:
ALTER TABLE table_name
{
| ALTER COLUMN column_name ENCODE new_encode_type
https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html