云数据库 GaussDB-使用:示例

时间:2023-11-01 16:22:02

示例

--准备数据。openGauss=# CREATE TABLE t1(c1 int, c2 int);openGauss=# INSERT INTO t1 VALUES(1, 1);openGauss=# INSERT INTO t1 VALUES(2, 2);--创建增量物化视图。openGauss=# CREATE INCREMENTAL MATERIALIZED VIEW mv AS SELECT * FROM t1;CREATE MATERIALIZED VIEW--插入数据。openGauss=# INSERT INTO t1 VALUES(3, 3);INSERT 0 1--增量刷新物化视图。openGauss=# REFRESH INCREMENTAL MATERIALIZED VIEW mv;REFRESH MATERIALIZED VIEW--查询物化视图结果。openGauss=# SELECT * FROM mv; c1 | c2 ----+----  1 |  1  2 |  2  3 |  3(3 rows)--插入数据。openGauss=# INSERT INTO t1 VALUES(4, 4);INSERT 0 1--全量刷新物化视图。openGauss=# REFRESH MATERIALIZED VIEW mv;REFRESH MATERIALIZED VIEW--查询物化视图结果。openGauss=# select * from mv; c1 | c2 ----+----  1 |  1  2 |  2  3 |  3  4 |  4(4 rows)--删除物化视图。openGauss=# DROP MATERIALIZED VIEW mv;DROP MATERIALIZED VIEW
support.huaweicloud.com/centralized-devg-v2-opengauss/devg_03_1342.html