ALTER EXTERNAL TABLE 示例 - Amazon Redshift
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

ALTER EXTERNAL TABLE 示例

以下示例使用位于美国东部(弗吉尼亚州北部)区域(us-east-1)Amazon Web Services 区域的 Amazon S3 存储桶,以及在 示例 中为 CREATE TABLE 创建的示例表。有关如何将分区与外部表一起使用的更多信息,请参阅对 Redshift Spectrum 外部表进行分区

以下示例将 SPECTRUM.SALES 外部表的 numRows 表属性设置为 170000 行。

alter table spectrum.sales set table properties ('numRows'='170000');

以下示例更改 SPECTRUM.SALES 外部表的位置。

alter table spectrum.sales set location 's3://redshift-downloads/tickit/spectrum/sales/';

以下示例将 SPECTRUM.SALES 外部表的格式更改为 Parquet。

alter table spectrum.sales set file format parquet;

以下示例为表 SPECTRUM.SALES_PART 添加一个分区。

alter table spectrum.sales_part add if not exists partition(saledate='2008-01-01') location 's3://redshift-downloads/tickit/spectrum/sales_partition/saledate=2008-01/';

以下示例为表 SPECTRUM.SALES_PART 添加三个分区。

alter table spectrum.sales_part add if not exists partition(saledate='2008-01-01') location 's3://redshift-downloads/tickit/spectrum/sales_partition/saledate=2008-01/' partition(saledate='2008-02-01') location 's3://redshift-downloads/tickit/spectrum/sales_partition/saledate=2008-02/' partition(saledate='2008-03-01') location 's3://redshift-downloads/tickit/spectrum/sales_partition/saledate=2008-03/';

以下示例修改 SPECTRUM.SALES_PART 以删除包含 saledate='2008-01-01'' 的分区。

alter table spectrum.sales_part drop partition(saledate='2008-01-01');

以下示例为包含 saledate='2008-01-01' 的分区设置新的 Amazon S3 路径。

alter table spectrum.sales_part partition(saledate='2008-01-01') set location 's3://redshift-downloads/tickit/spectrum/sales_partition/saledate=2008-01-01/';

以下示例将 sales_date 的名称更改为 transaction_date

alter table spectrum.sales rename column sales_date to transaction_date;

以下示例将列映射设置为使用优化行列式 (ORC) 格式的外部表的位置映射。

alter table spectrum.orc_example set table properties('orc.schema.resolution'='position');

以下示例将列映射设置为使用 ORC 格式的外部表的名称映射。

alter table spectrum.orc_example set table properties('orc.schema.resolution'='name');