CREATE_MATERIALIZED_VIEW — define a new materialized view
| Use Case | Command | Description |
|---|---|---|
| Create a materialized view | CREATE MATERIALIZED VIEW view_name AS select_query; | Defines and populates a new materialized view. |
| Create an empty materialized view | CREATE MATERIALIZED VIEW view_name AS select_query WITH NO DATA; | Defines the view but marks it as unscannable until refreshed. |
| Create with specific columns | CREATE MATERIALIZED VIEW view_name (col1, col2) AS select_query; | Creates a materialized view with specific column names. |
| Create with storage parameters | CREATE MATERIALIZED VIEW view_name WITH (fillfactor = 90) AS select_query; | Creates a materialized view with custom storage settings. |
| Create in a specific tablespace | CREATE MATERIALIZED VIEW view_name TABLESPACE fast_space AS select_query; | Stores the materialized view data in a specific tablespace. |
| Create if not exists | CREATE MATERIALIZED VIEW IF NOT EXISTS view_name AS select_query; | Creates a materialized view only if it doesn't already exist. |
CREATE MATERIALIZED VIEW [ IF NOT EXISTS ] table_name
[ (column_name [, ...] ) ]
[ USING method ]
[ WITH ( storage_parameter [= value] [, ... ] ) ]
[ TABLESPACE tablespace_name ]
AS query
[ WITH [ NO ] DATA ]
CREATE MATERIALIZED VIEW defines a materialized view of a query. The query is executed and used to populate the view at the time the command is issued (unless WITH NO DATA is used) and may be refreshed later using REFRESH MATERIALIZED VIEW.
CREATE MATERIALIZED VIEW is similar to CREATE TABLE AS, except that it also remembers the query used to initialize the view, so that it can be refreshed later upon demand. A materialized view has many of the same properties as a table, but there is no support for temporary materialized views.
CREATE MATERIALIZED VIEW requires CREATE privilege on the schema used for the materialized view.
IF NOT EXISTStable_namecolumn_nameUSING methodWITH ( storage_parameter [= value] [, ... ] )TABLESPACE tablespace_namequeryWITH [ NO ] DATACREATE MATERIALIZED VIEW is a PostgreSQL extension.
PostgreSQL 14.23 2026 CREATE MATERIALIZED VIEW(7)
Generated by phpman v4.9.26-5-g7740029 Author: Che Dong Under GNU General Public License
2026-08-14 21:37 @2600:1f28:365:80b0:4d23:66fa:c2bb:7bae
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)