REFRESH MATERIALIZED VIEW
Function
REFRESH MATERIALIZED VIEW refreshes the materialized view in full refresh mode.
Precautions
- Full refreshing can be performed on both full and incremental materialized views.
- To refresh a materialized view, you must have the SELECT permission on the base table.
Syntax
REFRESH MATERIALIZED VIEW mv_name;
Parameter Description
mv_name
Name of the materialized view to be refreshed.
Example
-- Create an ordinary table.
postgres=# CREATE TABLE my_table (c1 int, c2 int);
-- Create a full materialized view.
postgres=# CREATE MATERIALIZED VIEW my_mv AS SELECT * FROM my_table;
-- Create an incremental materialized view.
postgres=# CREATE INCREMENTAL MATERIALIZED VIEW my_imv AS SELECT * FROM my_table;
-- Write data to the base table.
postgres=# INSERT INTO my_table VALUES(1,1),(2,2);
-- Refresh the full materialized view my_mv.
postgres=# REFRESH MATERIALIZED VIEW my_mv;
-- Fully refresh the incremental materialized view my_imv.
postgres=# REFRESH MATERIALIZED VIEW my_imv;
Link
ALTER MATERIALIZED VIEW, CREATE INCREMENTAL MATERIALIZED VIEW, CREATE MATERIALIZED VIEW, CREATE TABLE, DROP MATERIALIZED VIEW, REFRESH INCREMENTAL MATERIALIZED VIEW
Feedback