2 .\" Title: ALTER MATERIALIZED VIEW
3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "ALTER MATERIALIZED VIEW" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 ALTER_MATERIALIZED_VIEW \- change the definition of a materialized view
35 ALTER MATERIALIZED VIEW [ IF EXISTS ] \fIname\fR
36 \fIaction\fR [, \&.\&.\&. ]
37 ALTER MATERIALIZED VIEW \fIname\fR
38 [ NO ] DEPENDS ON EXTENSION \fIextension_name\fR
39 ALTER MATERIALIZED VIEW [ IF EXISTS ] \fIname\fR
40 RENAME [ COLUMN ] \fIcolumn_name\fR TO \fInew_column_name\fR
41 ALTER MATERIALIZED VIEW [ IF EXISTS ] \fIname\fR
42 RENAME TO \fInew_name\fR
43 ALTER MATERIALIZED VIEW [ IF EXISTS ] \fIname\fR
44 SET SCHEMA \fInew_schema\fR
45 ALTER MATERIALIZED VIEW ALL IN TABLESPACE \fIname\fR [ OWNED BY \fIrole_name\fR [, \&.\&.\&. ] ]
46 SET TABLESPACE \fInew_tablespace\fR [ NOWAIT ]
48 where \fIaction\fR is one of:
50 ALTER [ COLUMN ] \fIcolumn_name\fR SET STATISTICS \fIinteger\fR
51 ALTER [ COLUMN ] \fIcolumn_name\fR SET ( \fIattribute_option\fR = \fIvalue\fR [, \&.\&.\&. ] )
52 ALTER [ COLUMN ] \fIcolumn_name\fR RESET ( \fIattribute_option\fR [, \&.\&.\&. ] )
53 ALTER [ COLUMN ] \fIcolumn_name\fR SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN | DEFAULT }
54 ALTER [ COLUMN ] \fIcolumn_name\fR SET COMPRESSION \fIcompression_method\fR
55 CLUSTER ON \fIindex_name\fR
57 SET ACCESS METHOD \fInew_access_method\fR
58 SET TABLESPACE \fInew_tablespace\fR
59 SET ( \fIstorage_parameter\fR [= \fIvalue\fR] [, \&.\&.\&. ] )
60 RESET ( \fIstorage_parameter\fR [, \&.\&.\&. ] )
61 OWNER TO { \fInew_owner\fR | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
65 \fBALTER MATERIALIZED VIEW\fR
66 changes various auxiliary properties of an existing materialized view\&.
68 You must own the materialized view to use
69 \fBALTER MATERIALIZED VIEW\fR\&. To change a materialized view\*(Aqs schema, you must also have
71 privilege on the new schema\&. To alter the owner, you must be able to
73 to the new owning role, and that role must have
75 privilege on the materialized view\*(Aqs schema\&. (These restrictions enforce that altering the owner doesn\*(Aqt do anything you couldn\*(Aqt do by dropping and recreating the materialized view\&. However, a superuser can alter ownership of any view anyway\&.)
77 The statement subforms and actions available for
78 \fBALTER MATERIALIZED VIEW\fR
79 are a subset of those available for
80 \fBALTER TABLE\fR, and have the same meaning when used for materialized views\&. See the descriptions for
87 The name (optionally schema\-qualified) of an existing materialized view\&.
92 Name of an existing column\&.
97 The name of the extension that the materialized view is to depend on (or no longer dependent on, if
99 is specified)\&. A materialized view that\*(Aqs marked as dependent on an extension is automatically dropped when the extension is dropped\&.
102 \fInew_column_name\fR
104 New name for an existing column\&.
109 The user name of the new owner of the materialized view\&.
114 The new name for the materialized view\&.
119 The new schema for the materialized view\&.
123 To rename the materialized view
132 ALTER MATERIALIZED VIEW foo RENAME TO bar;
139 \fBALTER MATERIALIZED VIEW\fR
144 CREATE MATERIALIZED VIEW (\fBCREATE_MATERIALIZED_VIEW\fR(7)), DROP MATERIALIZED VIEW (\fBDROP_MATERIALIZED_VIEW\fR(7)), REFRESH MATERIALIZED VIEW (\fBREFRESH_MATERIALIZED_VIEW\fR(7))