REFRESH MATERIALIZED VIEW
是用于更新物化视图的DDL命令。
REFRESH MATERIALIZED VIEW
添加于 PostgreSQL 9.3。
更改历史
- PostgreSQL 9.4
REFRESH MATERIALIZED VIEW CONCURRENTLY
添加 (提交 cc1965a9)
- PostgreSQL 9.3
- 添加 (提交 3bf3ab8c)
示例
REFRESH MATERIALIZED VIEW
的基本用法示例
postgres=# CREATE TABLE foo (id INT, val TEXT); CREATE TABLE postgres=# INSERT INTO foo VALUES(1, 'bar'); INSERT 0 1 postgres=# CREATE MATERIALIZED VIEW bar AS SELECT * FROM foo; SELECT 1 postgres=# INSERT INTO foo VALUES(2, 'baz'); INSERT 0 1 postgres=# SELECT * FROM bar; id | val ----+----- 1 | bar (1 row) postgres=# REFRESH MATERIALIZED VIEW bar; REFRESH MATERIALIZED VIEW postgres=# SELECT * FROM bar; id | val ----+----- 1 | bar 2 | baz (2 rows)
参考文献
- PostgreSQL文档: REFRESH MATERIALIZED VIEW