2 CREATE MATERIALIZED VIEW
4 CREATE MATERIALIZED VIEW — define a new materialized view
8 CREATE MATERIALIZED VIEW [ IF NOT EXISTS ] table_name
9 [ (column_name [, ...] ) ]
11 [ WITH ( storage_parameter [= value] [, ... ] ) ]
12 [ TABLESPACE tablespace_name ]
18 CREATE MATERIALIZED VIEW defines a materialized view of a query. The
19 query is executed and used to populate the view at the time the command
20 is issued (unless WITH NO DATA is used) and may be refreshed later
21 using REFRESH MATERIALIZED VIEW.
23 CREATE MATERIALIZED VIEW is similar to CREATE TABLE AS, except that it
24 also remembers the query used to initialize the view, so that it can be
25 refreshed later upon demand. A materialized view has many of the same
26 properties as a table, but there is no support for temporary
29 CREATE MATERIALIZED VIEW requires CREATE privilege on the schema used
30 for the materialized view.
35 Do not throw an error if a materialized view with the same name
36 already exists. A notice is issued in this case. Note that there
37 is no guarantee that the existing materialized view is anything
38 like the one that would have been created.
41 The name (optionally schema-qualified) of the materialized view
42 to be created. The name must be distinct from the name of any
43 other relation (table, sequence, index, view, materialized view,
44 or foreign table) in the same schema.
47 The name of a column in the new materialized view. If column
48 names are not provided, they are taken from the output column
52 This optional clause specifies the table access method to use to
53 store the contents for the new materialized view; the method
54 needs be an access method of type TABLE. See Chapter 62 for more
55 information. If this option is not specified, the default table
56 access method is chosen for the new materialized view. See
57 default_table_access_method for more information.
59 WITH ( storage_parameter [= value] [, ... ] )
60 This clause specifies optional storage parameters for the new
61 materialized view; see Storage Parameters in the CREATE TABLE
62 documentation for more information. All parameters supported for
63 CREATE TABLE are also supported for CREATE MATERIALIZED VIEW.
64 See CREATE TABLE for more information.
66 TABLESPACE tablespace_name
67 The tablespace_name is the name of the tablespace in which the
68 new materialized view is to be created. If not specified,
69 default_tablespace is consulted.
72 A SELECT, TABLE, or VALUES command. This query will run within a
73 security-restricted operation; in particular, calls to functions
74 that themselves create temporary tables will fail. Also, while
75 the query is running, the search_path is temporarily changed to
79 This clause specifies whether or not the materialized view
80 should be populated at creation time. If not, the materialized
81 view will be flagged as unscannable and cannot be queried until
82 REFRESH MATERIALIZED VIEW is used.
86 CREATE MATERIALIZED VIEW is a PostgreSQL extension.
90 ALTER MATERIALIZED VIEW, CREATE TABLE AS, CREATE VIEW, DROP
91 MATERIALIZED VIEW, REFRESH MATERIALIZED VIEW