Selecione suas preferências de cookies

Usamos cookies essenciais e ferramentas semelhantes que são necessárias para fornecer nosso site e serviços. Usamos cookies de desempenho para coletar estatísticas anônimas, para que possamos entender como os clientes usam nosso site e fazer as devidas melhorias. Cookies essenciais não podem ser desativados, mas você pode clicar em “Personalizar” ou “Recusar” para recusar cookies de desempenho.

Se você concordar, a AWS e terceiros aprovados também usarão cookies para fornecer recursos úteis do site, lembrar suas preferências e exibir conteúdo relevante, incluindo publicidade relevante. Para aceitar ou recusar todos os cookies não essenciais, clique em “Aceitar” ou “Recusar”. Para fazer escolhas mais detalhadas, clique em “Personalizar”.

Exemplos de DISTSTYLE e SORTKEY para ALTER MATERIALIZED VIEW - Amazon Redshift

Exemplos de DISTSTYLE e SORTKEY para ALTER MATERIALIZED VIEW

Os exemplos neste tópico mostram como realizar alterações DISTSTYLE e SORTKEY utilizando ALTER MATERIALIZED VIEW.

Os seguintes exemplos de consulta mostram como alterar uma coluna DISTSTYLE KEY DISTKEY usando um exemplo de tabela base:

CREATE TABLE base_inventory( inv_date_sk int4 NOT NULL, inv_item_sk int4 NOT NULL, inv_warehouse_sk int4 NOT NULL, inv_quantity_on_hand int4 ); INSERT INTO base_inventory VALUES(1,1,1,1); CREATE materialized VIEW inventory diststyle even AS SELECT * FROM base_inventory; SELECT "table", diststyle FROM svv_table_info WHERE "table" = 'inventory'; ALTER materialized VIEW inventory ALTER diststyle KEY distkey inv_warehouse_sk; SELECT "table", diststyle FROM svv_table_info WHERE "table" = 'inventory'; ALTER materialized VIEW inventory ALTER distkey inv_item_sk; SELECT "table", diststyle FROM svv_table_info WHERE "table" = 'inventory'; DROP TABLE base_inventory CASCADE;

Altere uma visão materializada para DISTSTYLE ALL:

CREATE TABLE base_inventory( inv_date_sk int4 NOT NULL, inv_item_sk int4 NOT NULL, inv_warehouse_sk int4 NOT NULL, inv_quantity_on_hand int4 ); INSERT INTO base_inventory VALUES(1,1,1,1); CREATE materialized VIEW inventory diststyle even AS SELECT * FROM base_inventory; SELECT "table", diststyle FROM svv_table_info WHERE "table" = 'inventory'; ALTER MATERIALIZED VIEW inventory ALTER diststyle ALL; SELECT "table", diststyle FROM svv_table_info WHERE "table" = 'inventory'; DROP TABLE base_inventory CASCADE;

Os seguintes comandos mostram exemplos de ALTER MATERIALIZED VIEW SORTKEY usando uma tabela base de amostra:

CREATE TABLE base_inventory (c0 int, c1 int); INSERT INTO base_inventory VALUES(1,1); CREATE materialized VIEW inventory interleaved sortkey(c0, c1) AS SELECT * FROM base_inventory; SELECT "table", sortkey1 FROM svv_table_info WHERE "table" = 'inventory'; ALTER materialized VIEW inventory ALTER sortkey(c0, c1); SELECT "table", diststyle, sortkey_num FROM svv_table_info WHERE "table" = 'inventory'; ALTER materialized VIEW inventory ALTER sortkey NONE; SELECT "table", diststyle, sortkey_num FROM svv_table_info WHERE "table" = 'inventory'; ALTER materialized VIEW inventory ALTER sortkey(c0); SELECT "table", diststyle, sortkey_num FROM svv_table_info WHERE "table" = 'inventory'; DROP TABLE base_inventory CASCADE;
PrivacidadeTermos do sitePreferências de cookies
© 2025, Amazon Web Services, Inc. ou suas afiliadas. Todos os direitos reservados.