顯示外部資料表 - Amazon Redshift

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

顯示外部資料表

顯示外部表的定義,包括表屬性和列屬性。您可以使用 SHOW EXTABLE 語句的輸出來重新建立資料表。

如需有關建立外部資料表的詳細資訊,請參CREATE EXTERNAL TABLE

Syntax (語法)

SHOW EXTERNAL TABLE external_schema.table_name [ PARTITION ]

參數

外部架構

關聯外部結構描述的名稱。

table_name

要顯示的資料表的名稱。

PARTITION

顯示 ALTER TABLE 語句,以便將分割區新增至資料表定義。

範例

以下示例基於以下定義的外部表:

CREATE EXTERNAL TABLE my_schema.alldatatypes_parquet_test_partitioned ( csmallint smallint, cint int, cbigint bigint, cfloat float4, cdouble float8, cchar char(10), cvarchar varchar(255), cdecimal_small decimal(18,9), cdecimal_big decimal(30,15), ctimestamp TIMESTAMP, cboolean boolean, cstring varchar(16383) ) PARTITIONED BY (cdate date, ctime TIMESTAMP) STORED AS PARQUET LOCATION 's3://mybucket-test-copy/alldatatypes_parquet_partitioned';

下面是表的「顯示外部表」命令和輸出示例my_schema.alldatatypes_parquet_test_partitioned

SHOW EXTERNAL TABLE my_schema.alldatatypes_parquet_test_partitioned;
"CREATE EXTERNAL TABLE my_schema.alldatatypes_parquet_test_partitioned ( csmallint smallint, cint int, cbigint bigint, cfloat float4, cdouble float8, cchar char(10), cvarchar varchar(255), cdecimal_small decimal(18,9), cdecimal_big decimal(30,15), ctimestamp timestamp, cboolean boolean, cstring varchar(16383) ) PARTITIONED BY (cdate date, ctime timestamp) ROW FORMAT SERDE 'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe' STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat' LOCATION 's3://mybucket-test-copy/alldatatypes_parquet_partitioned';"

以下是使用「顯示外部表」命令和輸出的示例PARTITION參數。輸出中包含 ALTER TABLE 陳述式,用於將分割區新增至資料表定義。

SHOW EXTERNAL TABLE my_schema.alldatatypes_parquet_test_partitioned PARTITION;
"CREATE EXTERNAL TABLE my_schema.alldatatypes_parquet_test_partitioned ( csmallint smallint, cint int, cbigint bigint, cfloat float4, cdouble float8, cchar char(10), cvarchar varchar(255), cdecimal_small decimal(18,9), cdecimal_big decimal(30,15), ctimestamp timestamp, cboolean boolean, cstring varchar(16383) ) PARTITIONED BY (cdate date) ROW FORMAT SERDE 'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe' STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat' LOCATION 's3://mybucket-test-copy/alldatatypes_parquet_partitioned'; ALTER TABLE my_schema.alldatatypes_parquet_test_partitioned ADD IF NOT EXISTS PARTITION (cdate='2021-01-01') LOCATION 's3://mybucket-test-copy/alldatatypes_parquet_partitioned2/cdate=2021-01-01'; ALTER TABLE my_schema.alldatatypes_parquet_test_partitioned ADD IF NOT EXISTS PARTITION (cdate='2021-01-02') LOCATION 's3://mybucket-test-copy/alldatatypes_parquet_partitioned2/cdate=2021-01-02';"