1CREATE MATERIALIZED VIEW(7P)ostgreSQL 12.2 DocumentatiCoRnEATE MATERIALIZED VIEW(7)
2
3
4

NAME

6       CREATE_MATERIALIZED_VIEW - define a new materialized view
7

SYNOPSIS

9       CREATE MATERIALIZED VIEW [ IF NOT EXISTS ] table_name
10           [ (column_name [, ...] ) ]
11           [ USING method ]
12           [ WITH ( storage_parameter [= value] [, ... ] ) ]
13           [ TABLESPACE tablespace_name ]
14           AS query
15           [ WITH [ NO ] DATA ]
16

DESCRIPTION

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.
22
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
27       materialized views.
28

PARAMETERS

30       IF NOT EXISTS
31           Do not throw an error if a materialized view with the same name
32           already exists. A notice is issued in this case. Note that there is
33           no guarantee that the existing materialized view is anything like
34           the one that would have been created.
35
36       table_name
37           The name (optionally schema-qualified) of the materialized view to
38           be created.
39
40       column_name
41           The name of a column in the new materialized view. If column names
42           are not provided, they are taken from the output column names of
43           the query.
44
45       USING method
46           This optional clause specifies the table access method to use to
47           store the contents for the new materialized view; the method needs
48           be an access method of type TABLE. See Chapter 60 for more
49           information. If this option is not specified, the default table
50           access method is chosen for the new materialized view. See
51           default_table_access_method for more information.
52
53       WITH ( storage_parameter [= value] [, ... ] )
54           This clause specifies optional storage parameters for the new
55           materialized view; see Storage Parameters for more information. All
56           parameters supported for CREATE TABLE are also supported for CREATE
57           MATERIALIZED VIEW. See CREATE TABLE (CREATE_TABLE(7)) for more
58           information.
59
60       TABLESPACE tablespace_name
61           The tablespace_name is the name of the tablespace in which the new
62           materialized view is to be created. If not specified,
63           default_tablespace is consulted.
64
65       query
66           A SELECT(7), TABLE, or VALUES(7) command. This query will run
67           within a security-restricted operation; in particular, calls to
68           functions that themselves create temporary tables will fail.
69
70       WITH [ NO ] DATA
71           This clause specifies whether or not the materialized view should
72           be populated at creation time. If not, the materialized view will
73           be flagged as unscannable and cannot be queried until REFRESH
74           MATERIALIZED VIEW is used.
75

COMPATIBILITY

77       CREATE MATERIALIZED VIEW is a PostgreSQL extension.
78

SEE ALSO

80       ALTER MATERIALIZED VIEW (ALTER_MATERIALIZED_VIEW(7)), CREATE TABLE AS
81       (CREATE_TABLE_AS(7)), CREATE VIEW (CREATE_VIEW(7)), DROP MATERIALIZED
82       VIEW (DROP_MATERIALIZED_VIEW(7)), REFRESH MATERIALIZED VIEW
83       (REFRESH_MATERIALIZED_VIEW(7))
84
85
86
87PostgreSQL 12.2                      2020          CREATE MATERIALIZED VIEW(7)
Impressum