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

SHOW TABLE

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

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

语法

SHOW TABLE [schema_name.]table_name

参数

schema_name

(可选)相关 schema 的名称。

table_name

要显示的表的名称。

示例

以下是表 sales 的 SHOW TABLE 输出示例。

show table sales;
CREATE TABLE public.sales ( salesid integer NOT NULL ENCODE az64, listid integer NOT NULL ENCODE az64 distkey, sellerid integer NOT NULL ENCODE az64, buyerid integer NOT NULL ENCODE az64, eventid integer NOT NULL ENCODE az64, dateid smallint NOT NULL, qtysold smallint NOT NULL ENCODE az64, pricepaid numeric(8,2) ENCODE az64, commission numeric(8,2) ENCODE az64, saletime timestamp without time zone ENCODE az64 ) DISTSTYLE KEY SORTKEY ( dateid );

以下是 schema public 中的表 category 的 SHOW TABLE 输出示例。

show table public.category;
CREATE TABLE public.category ( catid smallint NOT NULL distkey, catgroup character varying(10) ENCODE lzo, catname character varying(10) ENCODE lzo, catdesc character varying(50) ENCODE lzo ) DISTSTYLE KEY SORTKEY ( catid );

以下示例将使用主键创建表 foo

create table foo(a int PRIMARY KEY, b int);

SHOW TABLE 结果将显示 create 语句,以及 foo 表的所有属性。

show table foo;
CREATE TABLE public.foo ( a integer NOT NULL ENCODE az64, b integer ENCODE az64, PRIMARY KEY (a) ) DISTSTYLE AUTO;