1CREATE MATERIALIZED VIEW(7P)ostgreSQL 13.4 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 in the CREATE TABLE
56           (CREATE_TABLE(7)) documentation for more information. All
57           parameters supported for CREATE TABLE are also supported for CREATE
58           MATERIALIZED VIEW. See CREATE TABLE (CREATE_TABLE(7)) for more
59           information.
60
61       TABLESPACE tablespace_name
62           The tablespace_name is the name of the tablespace in which the new
63           materialized view is to be created. If not specified,
64           default_tablespace is consulted.
65
66       query
67           A SELECT(7), TABLE, or VALUES(7) command. This query will run
68           within a security-restricted operation; in particular, calls to
69           functions that themselves create temporary tables will fail.
70
71       WITH [ NO ] DATA
72           This clause specifies whether or not the materialized view should
73           be populated at creation time. If not, the materialized view will
74           be flagged as unscannable and cannot be queried until REFRESH
75           MATERIALIZED VIEW is used.
76

COMPATIBILITY

78       CREATE MATERIALIZED VIEW is a PostgreSQL extension.
79

SEE ALSO

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