CREATE MATERIALIZED VIEW v14
CREATE MATERIALIZED VIEW — Define a new materialized view.
CREATE MATERIALIZED VIEW defines a view of a query that isn't updated each time the view is referenced in a query. By default, the view is populated when the view is created. You can include the
BUILD DEFERRED keywords to delay populating the view.
A materialized view can be schema-qualified. If you specify a schema name when invoking the
CREATE MATERIALIZED VIEW command, the view is created in the specified schema. The view name must be different from the name of any other view, table, sequence, or index in the same schema.
The name (optionally schema-qualified) of a view to create.
SELECT statement that specifies the contents of the view.
build_clause to specify when to populate the view. Specify
BUILD IMMEDIATE or
BUILD IMMEDIATE(the default) populates the view immediately.
BUILD DEFERREDpopulates the view later, during a
create_mv_refresh clause to specify when to update the contents of a materialized view. The clause contains the
REFRESH keyword followed by optional
ON DEMAND keywords, where:
COMPLETEdiscards the current content and reloads the materialized view by executing the view's defining query when refreshing the materialized view.
ON DEMAND(the default) refreshes the materialized view on demand by calling the
DBMS_MVIEWpackage or by calling the Postgres
REFRESH MATERIALIZED VIEWstatement.
Materialized views are read-only. The server doesn't allow an
DELETE on a view.
Permissions of the view owner determine access to tables referenced in the view. The user of a view must have permissions to call all functions the view uses.
For more information about the Postgres
REFRESH MATERIALIZED VIEW command, see the PostgreSQL core documentation.
This statement creates a materialized view named
The view contains information retrieved from the
emp table about any employee that works in department