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

SHOW EXTERNAL TABLE

显示外部表的定义,包括表属性和列属性。您可以使用 SHOW EXTERNAL TABLE 语句的输出来重新创建表。

有关外部表创建的更多信息,请参阅CREATE EXTERNAL TABLE

Syntax

SHOW EXTERNAL TABLE external_schema.table_name [ PARTITION ]

Parameters

external_schema

关联的外部 schema 的名称。

table_name

要显示的表的名称。

PARTITION

显示 ALTER TABLE 语句以将分区添加到表定义。

Examples

以下示例基于定义如下的外部表:

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';

以下是 SHOW EXTERNAL TABLE 命令和表 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 参数时的 SHOW EXTERNAL TABLE 命令和输出的示例。输出包含 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';"