Table of Contents Previous Next


3 The SQL Language : 3.3 SQL Commands : 3.3.20 CREATE MATERIALIZED VIEW

CREATE MATERIALIZED VIEW -- define a new materialized view
CREATE MATERIALIZED VIEW name
[build_clause][create_mv_refresh] AS subquery
Where build_clause is:
Where create_mv_refresh is:
REFRESH [COMPLETE] [ON DEMAND]
CREATE MATERIALIZED VIEW defines a view of a query that is not 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 the population of the view.
A materialized view may be schema-qualified; if you specify a schema name when invoking the CREATE MATERIALIZED VIEW command, the view will be created in the specified schema. The view name must be distinct from the name of any other view, table, sequence, or index in the same schema.
A SELECT statement that specifies the contents of the view. Refer to SELECT for more information about valid queries.
Include a build_clause to specify when the view should be populated. Specify BUILD IMMEDIATE, or BUILD DEFERRED:
BUILD IMMEDIATE instructs the server to populate the view immediately. This is the default behavior.
BUILD DEFERRED instructs the server to populate the view at a later time (during a REFRESH operation).
Include the create_mv_refresh clause to specify when the contents of a materialized view should be updated. The clause contains the REFRESH keyword followed by COMPLETE and/or ON DEMAND, where:
COMPLETE instructs the server to discard the current content and reload the materialized view by executing the view's defining query when the materialized view is refreshed.
ON DEMAND instructs the server to refresh the materialized view on demand by calling the DBMS_MVIEW package or by calling the Postgres REFRESH MATERIALIZED VIEW statement. This is the default behavior.
Access to tables referenced in the view is determined by permissions of the view owner; the user of a view must have permissions to call all functions used by the view.
For more information about using the DBMS_MVIEW package to refresh a materialized view, please see Section 7.6.
For more information about the Postgres REFRESH MATERIALIZED VIEW command, please see the PostgreSQL Core Documentation available at:
The view contains information retrieved from the emp table about any employee that works in department 30.

3 The SQL Language : 3.3 SQL Commands : 3.3.20 CREATE MATERIALIZED VIEW

Table of Contents Previous Next