ALTER EXTERNAL TABLE 例
次の例では、米国東部 (バージニア北部) リージョン (us-east-1
) AWS リージョン にある Amazon S3 バケットおよび CREATE TABLE の 例 で作成されたテーブル例を使用します。外部テーブルでパーティションを使用する方法の詳細については、「Redshift Spectrum 外部テーブルのパーティション化」を参照してください。
次の例では、SPECTRUM.SALES 外部テーブルの numRows テーブルプロパティを 170,000 行に設定します。
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 テーブルに対して 1 つのパーティションを追加します。
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 テーブルに対して 3 つのパーティションを追加します。
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');