table of contents
CREATE MATERIALIZED VIEW(7) | PostgreSQL 15.9 Documentation | CREATE MATERIALIZED VIEW(7) |
NAME¶
CREATE_MATERIALIZED_VIEW - define a new materialized view
SYNOPSIS¶
CREATE MATERIALIZED VIEW [ IF NOT EXISTS ] table_name
[ (column_name [, ...] ) ]
[ USING method ]
[ WITH ( storage_parameter [= value] [, ... ] ) ]
[ TABLESPACE tablespace_name ]
AS query
[ WITH [ NO ] DATA ]
DESCRIPTION¶
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.
PARAMETERS¶
IF NOT EXISTS
table_name
column_name
USING method
WITH ( storage_parameter [= value] [, ... ] )
TABLESPACE tablespace_name
query
WITH [ NO ] DATA
COMPATIBILITY¶
CREATE MATERIALIZED VIEW is a PostgreSQL extension.
SEE ALSO¶
ALTER MATERIALIZED VIEW (ALTER_MATERIALIZED_VIEW(7)), CREATE TABLE AS (CREATE_TABLE_AS(7)), CREATE VIEW (CREATE_VIEW(7)), DROP MATERIALIZED VIEW (DROP_MATERIALIZED_VIEW(7)), REFRESH MATERIALIZED VIEW (REFRESH_MATERIALIZED_VIEW(7))
2024 | PostgreSQL 15.9 |