Seleccione sus preferencias de cookies

Usamos cookies esenciales y herramientas similares que son necesarias para proporcionar nuestro sitio y nuestros servicios. Usamos cookies de rendimiento para recopilar estadísticas anónimas para que podamos entender cómo los clientes usan nuestro sitio y hacer mejoras. Las cookies esenciales no se pueden desactivar, pero puede hacer clic en “Personalizar” o “Rechazar” para rechazar las cookies de rendimiento.

Si está de acuerdo, AWS y los terceros aprobados también utilizarán cookies para proporcionar características útiles del sitio, recordar sus preferencias y mostrar contenido relevante, incluida publicidad relevante. Para aceptar o rechazar todas las cookies no esenciales, haga clic en “Aceptar” o “Rechazar”. Para elegir opciones más detalladas, haga clic en “Personalizar”.

Ejemplos de DISTSTYLE y SORTKEY para ALTER MATERIALIZED VIEW - Amazon Redshift

Ejemplos de DISTSTYLE y SORTKEY para ALTER MATERIALIZED VIEW

En los ejemplos de este tema se muestra cómo realizar cambios en DISTSTYLE y SORTKEY mediante ALTER MATERIALIZED VIEW.

Las consultas de ejemplo siguientes muestran cómo modificar una columna DISTSTYLE KEY DISTKEY mediante una tabla base de ejemplo:

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;

Modifique una vista materializada a 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;

Los siguientes comandos muestran ejemplos de ALTER MATERIALIZED VIEW SORTKEY, con una tabla base de ejemplo:

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;
PrivacidadTérminos del sitioPreferencias de cookies
© 2025, Amazon Web Services, Inc o sus afiliados. Todos los derechos reservados.