Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.
Beispiele für DISTSTYLE und SORTKEY für ALTER MATERIALIZED VIEW
Die Beispiele in diesem Thema zeigen, wie Sie DISTSTYLE- und SORTKEY-Änderungen mithilfe von ALTER MATERIALIZED VIEW vornehmen.
Die folgenden Beispielabfragen zeigen, wie Sie eine DISTSTYLE KEY DISTKEY-Spalte anhand einer Beispiel-Basistabelle ändern können:
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;
Ändern Sie eine materialisierte Ansicht in 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;
Die folgenden Befehle zeigen SORTKEY-Beispiele für ALTER MATERIALIZED VIEW anhand einer Beispiel-Basistabelle:
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;