diff options
Diffstat (limited to 'doc/src/sgml/man7/CREATE_MATERIALIZED_VIEW.7')
-rw-r--r-- | doc/src/sgml/man7/CREATE_MATERIALIZED_VIEW.7 | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/doc/src/sgml/man7/CREATE_MATERIALIZED_VIEW.7 b/doc/src/sgml/man7/CREATE_MATERIALIZED_VIEW.7 new file mode 100644 index 0000000..2ac8bb9 --- /dev/null +++ b/doc/src/sgml/man7/CREATE_MATERIALIZED_VIEW.7 @@ -0,0 +1,131 @@ +'\" t +.\" Title: CREATE MATERIALIZED VIEW +.\" Author: The PostgreSQL Global Development Group +.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/> +.\" Date: 2023 +.\" Manual: PostgreSQL 15.5 Documentation +.\" Source: PostgreSQL 15.5 +.\" Language: English +.\" +.TH "CREATE MATERIALIZED VIEW" "7" "2023" "PostgreSQL 15.5" "PostgreSQL 15.5 Documentation" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +CREATE_MATERIALIZED_VIEW \- define a new materialized view +.SH "SYNOPSIS" +.sp +.nf +CREATE MATERIALIZED VIEW [ IF NOT EXISTS ] \fItable_name\fR + [ (\fIcolumn_name\fR [, \&.\&.\&.] ) ] + [ USING \fImethod\fR ] + [ WITH ( \fIstorage_parameter\fR [= \fIvalue\fR] [, \&.\&.\&. ] ) ] + [ TABLESPACE \fItablespace_name\fR ] + AS \fIquery\fR + [ WITH [ NO ] DATA ] +.fi +.SH "DESCRIPTION" +.PP +\fBCREATE MATERIALIZED VIEW\fR +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 +\fBWITH NO DATA\fR +is used) and may be refreshed later using +\fBREFRESH MATERIALIZED VIEW\fR\&. +.PP +\fBCREATE MATERIALIZED VIEW\fR +is similar to +\fBCREATE TABLE AS\fR, 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\&. +.PP +\fBCREATE MATERIALIZED VIEW\fR +requires +CREATE +privilege on the schema used for the materialized view\&. +.SH "PARAMETERS" +.PP +IF NOT EXISTS +.RS 4 +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\&. +.RE +.PP +\fItable_name\fR +.RS 4 +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\&. +.RE +.PP +\fIcolumn_name\fR +.RS 4 +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\&. +.RE +.PP +USING \fImethod\fR +.RS 4 +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\&. +.RE +.PP +WITH ( \fIstorage_parameter\fR [= \fIvalue\fR] [, \&.\&.\&. ] ) +.RS 4 +This clause specifies optional storage parameters for the new materialized view; see +Storage Parameters +in the +CREATE TABLE (\fBCREATE_TABLE\fR(7)) +documentation for more information\&. All parameters supported for +CREATE TABLE +are also supported for +CREATE MATERIALIZED VIEW\&. See +CREATE TABLE (\fBCREATE_TABLE\fR(7)) +for more information\&. +.RE +.PP +TABLESPACE \fItablespace_name\fR +.RS 4 +The +\fItablespace_name\fR +is the name of the tablespace in which the new materialized view is to be created\&. If not specified, +default_tablespace +is consulted\&. +.RE +.PP +\fIquery\fR +.RS 4 +A +\fBSELECT\fR, +\fBTABLE\fR, or +\fBVALUES\fR +command\&. This query will run within a security\-restricted operation; in particular, calls to functions that themselves create temporary tables will fail\&. +.RE +.PP +WITH [ NO ] DATA +.RS 4 +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 +\fBREFRESH MATERIALIZED VIEW\fR +is used\&. +.RE +.SH "COMPATIBILITY" +.PP +\fBCREATE MATERIALIZED VIEW\fR +is a +PostgreSQL +extension\&. +.SH "SEE ALSO" +ALTER MATERIALIZED VIEW (\fBALTER_MATERIALIZED_VIEW\fR(7)), CREATE TABLE AS (\fBCREATE_TABLE_AS\fR(7)), CREATE VIEW (\fBCREATE_VIEW\fR(7)), DROP MATERIALIZED VIEW (\fBDROP_MATERIALIZED_VIEW\fR(7)), REFRESH MATERIALIZED VIEW (\fBREFRESH_MATERIALIZED_VIEW\fR(7)) |