1CREATE MATERIALIZED VIEW(7P)ostgreSQL 11.6 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           [ WITH ( storage_parameter [= value] [, ... ] ) ]
12           [ TABLESPACE tablespace_name ]
13           AS query
14           [ WITH [ NO ] DATA ]
15

DESCRIPTION

17       CREATE MATERIALIZED VIEW defines a materialized view of a query. The
18       query is executed and used to populate the view at the time the command
19       is issued (unless WITH NO DATA is used) and may be refreshed later
20       using REFRESH MATERIALIZED VIEW.
21
22       CREATE MATERIALIZED VIEW is similar to CREATE TABLE AS, except that it
23       also remembers the query used to initialize the view, so that it can be
24       refreshed later upon demand. A materialized view has many of the same
25       properties as a table, but there is no support for temporary
26       materialized views or automatic generation of OIDs.
27

PARAMETERS

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

COMPATIBILITY

68       CREATE MATERIALIZED VIEW is a PostgreSQL extension.
69

SEE ALSO

71       ALTER MATERIALIZED VIEW (ALTER_MATERIALIZED_VIEW(7)), CREATE TABLE AS
72       (CREATE_TABLE_AS(7)), CREATE VIEW (CREATE_VIEW(7)), DROP MATERIALIZED
73       VIEW (DROP_MATERIALIZED_VIEW(7)), REFRESH MATERIALIZED VIEW
74       (REFRESH_MATERIALIZED_VIEW(7))
75
76
77
78PostgreSQL 11.6                      2019          CREATE MATERIALIZED VIEW(7)
Impressum