Help Center/ GaussDB/ Developer Guide(Centralized_8.x)/ SQL Reference/ SQL Syntax/ R/ REFRESH INCREMENTAL MATERIALIZED VIEW
Updated on 2024-06-03 GMT+08:00

REFRESH INCREMENTAL MATERIALIZED VIEW

Description

REFRESH INCREMENTAL MATERIALIZED VIEW refreshes a materialized view in incremental mode.

Precautions

  • Incremental refresh supports only fast-refresh materialized views.
  • To refresh a materialized view, you must have the SELECT permission on the base table.

Syntax

REFRESH INCREMENTAL MATERIALIZED VIEW mv_name;

Parameters

  • mv_name

    Name of the materialized view to be refreshed.

Examples

-- Create an ordinary table.
gaussdb=# CREATE TABLE my_table (c1 int, c2 int)
WITH(STORAGE_TYPE=ASTORE);

-- Create a fast-refresh materialized view.
gaussdb=# CREATE INCREMENTAL MATERIALIZED VIEW my_imv AS SELECT * FROM my_table;

-- Write data to the base table.
gaussdb=# INSERT INTO my_table VALUES(1,1),(2,2);

-- Fast refresh the fast-refresh materialized view my_imv.
gaussdb=# REFRESH INCREMENTAL MATERIALIZED VIEW my_imv;

-- View the fast-refresh materialized view.
gaussdb=# SELECT * FROM my_imv;
 c1 | c2 
----+----
  1 |  1
  2 |  2
(2 rows)

-- Delete the fast-refresh materialized view.
gaussdb=# DROP MATERIALIZED VIEW my_imv;

-- Delete the my_table table.
gaussdb=# DROP TABLE my_table;