summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/man7/ALTER_MATERIALIZED_VIEW.7
blob: 903d5301aface198154ed2631ba814384d3a3564 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
'\" t
.\"     Title: ALTER MATERIALIZED VIEW
.\"    Author: The PostgreSQL Global Development Group
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\"      Date: 2024
.\"    Manual: PostgreSQL 15.6 Documentation
.\"    Source: PostgreSQL 15.6
.\"  Language: English
.\"
.TH "ALTER MATERIALIZED VIEW" "7" "2024" "PostgreSQL 15.6" "PostgreSQL 15.6 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"
ALTER_MATERIALIZED_VIEW \- change the definition of a materialized view
.SH "SYNOPSIS"
.sp
.nf
ALTER MATERIALIZED VIEW [ IF EXISTS ] \fIname\fR
    \fIaction\fR [, \&.\&.\&. ]
ALTER MATERIALIZED VIEW \fIname\fR
    [ NO ] DEPENDS ON EXTENSION \fIextension_name\fR
ALTER MATERIALIZED VIEW [ IF EXISTS ] \fIname\fR
    RENAME [ COLUMN ] \fIcolumn_name\fR TO \fInew_column_name\fR
ALTER MATERIALIZED VIEW [ IF EXISTS ] \fIname\fR
    RENAME TO \fInew_name\fR
ALTER MATERIALIZED VIEW [ IF EXISTS ] \fIname\fR
    SET SCHEMA \fInew_schema\fR
ALTER MATERIALIZED VIEW ALL IN TABLESPACE \fIname\fR [ OWNED BY \fIrole_name\fR [, \&.\&.\&. ] ]
    SET TABLESPACE \fInew_tablespace\fR [ NOWAIT ]

where \fIaction\fR is one of:

    ALTER [ COLUMN ] \fIcolumn_name\fR SET STATISTICS \fIinteger\fR
    ALTER [ COLUMN ] \fIcolumn_name\fR SET ( \fIattribute_option\fR = \fIvalue\fR [, \&.\&.\&. ] )
    ALTER [ COLUMN ] \fIcolumn_name\fR RESET ( \fIattribute_option\fR [, \&.\&.\&. ] )
    ALTER [ COLUMN ] \fIcolumn_name\fR SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }
    ALTER [ COLUMN ] \fIcolumn_name\fR SET COMPRESSION \fIcompression_method\fR
    CLUSTER ON \fIindex_name\fR
    SET WITHOUT CLUSTER
    SET ACCESS METHOD \fInew_access_method\fR
    SET TABLESPACE \fInew_tablespace\fR
    SET ( \fIstorage_parameter\fR [= \fIvalue\fR] [, \&.\&.\&. ] )
    RESET ( \fIstorage_parameter\fR [, \&.\&.\&. ] )
    OWNER TO { \fInew_owner\fR | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
.fi
.SH "DESCRIPTION"
.PP
\fBALTER MATERIALIZED VIEW\fR
changes various auxiliary properties of an existing materialized view\&.
.PP
You must own the materialized view to use
\fBALTER MATERIALIZED VIEW\fR\&. To change a materialized view\*(Aqs schema, you must also have
CREATE
privilege on the new schema\&. To alter the owner, you must also be a direct or indirect member of the new owning role, and that role must have
CREATE
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\&.)
.PP
The statement subforms and actions available for
\fBALTER MATERIALIZED VIEW\fR
are a subset of those available for
\fBALTER TABLE\fR, and have the same meaning when used for materialized views\&. See the descriptions for
\fBALTER TABLE\fR
for details\&.
.SH "PARAMETERS"
.PP
\fIname\fR
.RS 4
The name (optionally schema\-qualified) of an existing materialized view\&.
.RE
.PP
\fIcolumn_name\fR
.RS 4
Name of a new or existing column\&.
.RE
.PP
\fIextension_name\fR
.RS 4
The name of the extension that the materialized view is to depend on (or no longer dependent on, if
NO
is specified)\&. A materialized view that\*(Aqs marked as dependent on an extension is automatically dropped when the extension is dropped\&.
.RE
.PP
\fInew_column_name\fR
.RS 4
New name for an existing column\&.
.RE
.PP
\fInew_owner\fR
.RS 4
The user name of the new owner of the materialized view\&.
.RE
.PP
\fInew_name\fR
.RS 4
The new name for the materialized view\&.
.RE
.PP
\fInew_schema\fR
.RS 4
The new schema for the materialized view\&.
.RE
.SH "EXAMPLES"
.PP
To rename the materialized view
foo
to
bar:
.sp
.if n \{\
.RS 4
.\}
.nf
ALTER MATERIALIZED VIEW foo RENAME TO bar;
.fi
.if n \{\
.RE
.\}
.SH "COMPATIBILITY"
.PP
\fBALTER MATERIALIZED VIEW\fR
is a
PostgreSQL
extension\&.
.SH "SEE ALSO"
CREATE MATERIALIZED VIEW (\fBCREATE_MATERIALIZED_VIEW\fR(7)), DROP MATERIALIZED VIEW (\fBDROP_MATERIALIZED_VIEW\fR(7)), REFRESH MATERIALIZED VIEW (\fBREFRESH_MATERIALIZED_VIEW\fR(7))