SHOW TABLE - Amazon Redshift

O Amazon Redshift não permitirá mais a criação de funções definidas pelo usuário (UDFs) do Python a partir de 1.º de novembro de 2025. Se quiser usar UDFs do Python, você deve criá-las antes dessa data. As UDFs do Python existentes continuarão a funcionar normalmente. Para ter mais informações, consulte a publicação de blog .

SHOW TABLE

Exibe a definição de uma tabela, incluindo atributos e restrições de tabela, atributos e agrupamento de colunas, bem como restrições de coluna. Use a saída da instrução SHOW TABLE para recriar a tabela.

Para obter mais informações sobre criação de tabelas, consulte CRIAR TABELA.

Sintaxe

SHOW TABLE [schema_name.]table_name

Parâmetros

schema_name

(Opcional) O nome do esquema relacionado.

table_name

O nome da tabela a ser exibida.

Exemplos

Segue-se um exemplo do comando e saída SHOW TABLE para a tabela sales.

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

Segue-se um exemplo da saída SHOW TABLE para a tabela category no esquema public. O agrupamento do banco de dados é CASE_SENSITIVE.

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

O exemplo a seguir cria a tabela foo com uma chave primária.

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

Os resultados SHOW TABLE exibem a instrução create com todas as propriedades da tabela foo.

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

Neste exemplo, criamos uma tabela em que a coluna a herda o agrupamento CASE_SENSITIVE padrão do banco de dados, enquanto b e c são explicitamente definidos como agrupamento CASE_INSENSITIVE.

CREATE TABLE public.foo ( a CHAR, b VARCHAR(10) COLLATE CASE_INSENSITIVE, c SUPER COLLATE CASE_INSENSITIVE );

Os resultados SHOW TABLE exibem a instrução create com todas as propriedades da tabela foo.

show table public.foo;
CREATE TABLE public.foo ( a character(1) ENCODE lzo COLLATE case_sensitive, b character varying(10) ENCODE lzo COLLATE case_insensitive, c super COLLATE case_insensitive ) DISTSTYLE AUTO;