# CREATE_MATERIALIZED_VIEW - define a new materialized view - man(7) - [phpMan]

_CREATE_ _MATERIALIZED_ [_VIEW_(7)](https://www.chedong.com/phpMan.php/man/VIEW/7/markdown)        PostgreSQL 16.14 Documentation        _CREATE_ _MATERIALIZED_ [_VIEW_(7)](https://www.chedong.com/phpMan.php/man/VIEW/7/markdown)

## 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
           Do not throw an error if a materialized view with the same name already exists. A notice
           is issued in this case. Note that there is no guarantee that the existing materialized
           view is anything like the one that would have been created.

       _table_name_
           The name (optionally schema-qualified) of the materialized view to be created. The name
           must be distinct from the name of any other relation (table, sequence, index, view,
           materialized view, or foreign table) in the same schema.

       _column_name_
           The name of a column in the new materialized view. If column names are not provided, they
           are taken from the output column names of the query.

       USING _method_
           This optional clause specifies the table access method to use to store the contents for
           the new materialized view; the method needs be an access method of type TABLE. See
           Chapter 63 for more information. If this option is not specified, the default table
           access method is chosen for the new materialized view. See default_table_access_method
           for more information.

       WITH ( _storage_parameter_ [= _value_] [, ... ] )
           This clause specifies optional storage parameters for the new materialized view; see
           Storage Parameters in the CREATE TABLE ([**CREATE_TABLE**(7)](https://www.chedong.com/phpMan.php/man/CREATETABLE/7/markdown)) documentation for more
           information. All parameters supported for CREATE TABLE are also supported for CREATE
           MATERIALIZED VIEW. See CREATE TABLE ([**CREATE_TABLE**(7)](https://www.chedong.com/phpMan.php/man/CREATETABLE/7/markdown)) for more information.

       TABLESPACE _tablespace_name_
           The _tablespace_name_ is the name of the tablespace in which the new materialized view is
           to be created. If not specified, default_tablespace is consulted.

       _query_
           A **SELECT**, **TABLE**, or **VALUES **command. This query will run within a security-restricted
           operation; in particular, calls to functions that themselves create temporary tables will
           fail.

       WITH [ NO ] DATA
           This clause specifies whether or not the materialized view should be populated at
           creation time. If not, the materialized view will be flagged as unscannable and cannot be
           queried until **REFRESH MATERIALIZED VIEW **is used.

## COMPATIBILITY
       **CREATE MATERIALIZED VIEW **is a PostgreSQL extension.

## SEE ALSO
       ALTER MATERIALIZED VIEW ([**ALTER_MATERIALIZED_VIEW**(7)](https://www.chedong.com/phpMan.php/man/ALTERMATERIALIZEDVIEW/7/markdown)), CREATE TABLE AS ([**CREATE_TABLE_AS**(7)](https://www.chedong.com/phpMan.php/man/CREATETABLEAS/7/markdown)),
       CREATE VIEW ([**CREATE_VIEW**(7)](https://www.chedong.com/phpMan.php/man/CREATEVIEW/7/markdown)), DROP MATERIALIZED VIEW ([**DROP_MATERIALIZED_VIEW**(7)](https://www.chedong.com/phpMan.php/man/DROPMATERIALIZEDVIEW/7/markdown)), REFRESH
       MATERIALIZED VIEW ([**REFRESH_MATERIALIZED_VIEW**(7)](https://www.chedong.com/phpMan.php/man/REFRESHMATERIALIZEDVIEW/7/markdown))

PostgreSQL 16.14                                2026                     _CREATE_ _MATERIALIZED_ [_VIEW_(7)](https://www.chedong.com/phpMan.php/man/VIEW/7/markdown)
