]> begriffs open source - ai-pg/blob - full-docs/man7/ALTER_MATERIALIZED_VIEW.7
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / man7 / ALTER_MATERIALIZED_VIEW.7
1 '\" t
2 .\"     Title: ALTER MATERIALIZED VIEW
3 .\"    Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5 .\"      Date: 2025
6 .\"    Manual: PostgreSQL 18.0 Documentation
7 .\"    Source: PostgreSQL 18.0
8 .\"  Language: English
9 .\"
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 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 ALTER_MATERIALIZED_VIEW \- change the definition of a materialized view
32 .SH "SYNOPSIS"
33 .sp
34 .nf
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 ]
47
48 where \fIaction\fR is one of:
49
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
56     SET WITHOUT CLUSTER
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 }
62 .fi
63 .SH "DESCRIPTION"
64 .PP
65 \fBALTER MATERIALIZED VIEW\fR
66 changes various auxiliary properties of an existing materialized view\&.
67 .PP
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
70 CREATE
71 privilege on the new schema\&. To alter the owner, you must be able to
72 SET ROLE
73 to the new owning role, and that role must have
74 CREATE
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\&.)
76 .PP
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
81 \fBALTER TABLE\fR
82 for details\&.
83 .SH "PARAMETERS"
84 .PP
85 \fIname\fR
86 .RS 4
87 The name (optionally schema\-qualified) of an existing materialized view\&.
88 .RE
89 .PP
90 \fIcolumn_name\fR
91 .RS 4
92 Name of an existing column\&.
93 .RE
94 .PP
95 \fIextension_name\fR
96 .RS 4
97 The name of the extension that the materialized view is to depend on (or no longer dependent on, if
98 NO
99 is specified)\&. A materialized view that\*(Aqs marked as dependent on an extension is automatically dropped when the extension is dropped\&.
100 .RE
101 .PP
102 \fInew_column_name\fR
103 .RS 4
104 New name for an existing column\&.
105 .RE
106 .PP
107 \fInew_owner\fR
108 .RS 4
109 The user name of the new owner of the materialized view\&.
110 .RE
111 .PP
112 \fInew_name\fR
113 .RS 4
114 The new name for the materialized view\&.
115 .RE
116 .PP
117 \fInew_schema\fR
118 .RS 4
119 The new schema for the materialized view\&.
120 .RE
121 .SH "EXAMPLES"
122 .PP
123 To rename the materialized view
124 foo
125 to
126 bar:
127 .sp
128 .if n \{\
129 .RS 4
130 .\}
131 .nf
132 ALTER MATERIALIZED VIEW foo RENAME TO bar;
133 .fi
134 .if n \{\
135 .RE
136 .\}
137 .SH "COMPATIBILITY"
138 .PP
139 \fBALTER MATERIALIZED VIEW\fR
140 is a
141 PostgreSQL
142 extension\&.
143 .SH "SEE ALSO"
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))