| 1 |
<!-- |
| 2 |
doc/src/sgml/ref/alter_materialized_view.sgml |
| 3 |
PostgreSQL documentation |
| 4 |
--> |
| 5 |
|
| 6 |
<refentry id="sql-altermaterializedview"> |
| 7 |
<indexterm zone="sql-altermaterializedview"> |
| 8 |
<primary>ALTER MATERIALIZED VIEW</primary> |
| 9 |
</indexterm> |
| 10 |
|
| 11 |
<refmeta> |
| 12 |
<refentrytitle>ALTER MATERIALIZED VIEW</refentrytitle> |
| 13 |
<manvolnum>7</manvolnum> |
| 14 |
<refmiscinfo>SQL - Language Statements</refmiscinfo> |
| 15 |
</refmeta> |
| 16 |
|
| 17 |
<refnamediv> |
| 18 |
<refname>ALTER MATERIALIZED VIEW</refname> |
| 19 |
<refpurpose>change the definition of a materialized view</refpurpose> |
| 20 |
</refnamediv> |
| 21 |
|
| 22 |
<refsynopsisdiv> |
| 23 |
<synopsis> |
| 24 |
ALTER MATERIALIZED VIEW [ IF EXISTS ] <replaceable class="parameter">name</replaceable> |
| 25 |
<replaceable class="parameter">action</replaceable> [, ... ] |
| 26 |
ALTER MATERIALIZED VIEW <replaceable class="parameter">name</replaceable> |
| 27 |
[ NO ] DEPENDS ON EXTENSION <replaceable class="parameter">extension_name</replaceable> |
| 28 |
ALTER MATERIALIZED VIEW [ IF EXISTS ] <replaceable class="parameter">name</replaceable> |
| 29 |
RENAME [ COLUMN ] <replaceable class="parameter">column_name</replaceable> TO <replaceable class="parameter">new_column_name</replaceable> |
| 30 |
ALTER MATERIALIZED VIEW [ IF EXISTS ] <replaceable class="parameter">name</replaceable> |
| 31 |
RENAME TO <replaceable class="parameter">new_name</replaceable> |
| 32 |
ALTER MATERIALIZED VIEW [ IF EXISTS ] <replaceable class="parameter">name</replaceable> |
| 33 |
SET SCHEMA <replaceable class="parameter">new_schema</replaceable> |
| 34 |
ALTER MATERIALIZED VIEW ALL IN TABLESPACE <replaceable class="parameter">name</replaceable> [ OWNED BY <replaceable class="parameter">role_name</replaceable> [, ... ] ] |
| 35 |
SET TABLESPACE <replaceable class="parameter">new_tablespace</replaceable> [ NOWAIT ] |
| 36 |
|
| 37 |
<phrase>where <replaceable class="parameter">action</replaceable> is one of:</phrase> |
| 38 |
|
| 39 |
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET STATISTICS <replaceable class="parameter">integer</replaceable> |
| 40 |
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET ( <replaceable class="parameter">attribute_option</replaceable> = <replaceable class="parameter">value</replaceable> [, ... ] ) |
| 41 |
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> RESET ( <replaceable class="parameter">attribute_option</replaceable> [, ... ] ) |
| 42 |
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN | DEFAULT } |
| 43 |
ALTER [ COLUMN ] <replaceable class="parameter">column_name</replaceable> SET COMPRESSION <replaceable class="parameter">compression_method</replaceable> |
| 44 |
CLUSTER ON <replaceable class="parameter">index_name</replaceable> |
| 45 |
SET WITHOUT CLUSTER |
| 46 |
SET ACCESS METHOD <replaceable class="parameter">new_access_method</replaceable> |
| 47 |
SET TABLESPACE <replaceable class="parameter">new_tablespace</replaceable> |
| 48 |
SET ( <replaceable class="parameter">storage_parameter</replaceable> [= <replaceable class="parameter">value</replaceable>] [, ... ] ) |
| 49 |
RESET ( <replaceable class="parameter">storage_parameter</replaceable> [, ... ] ) |
| 50 |
OWNER TO { <replaceable class="parameter">new_owner</replaceable> | CURRENT_ROLE | CURRENT_USER | SESSION_USER } |
| 51 |
</synopsis> |
| 52 |
</refsynopsisdiv> |
| 53 |
|
| 54 |
<refsect1> |
| 55 |
<title>Description</title> |
| 56 |
|
| 57 |
<para> |
| 58 |
<command>ALTER MATERIALIZED VIEW</command> changes various auxiliary |
| 59 |
properties of an existing materialized view. |
| 60 |
</para> |
| 61 |
|
| 62 |
<para> |
| 63 |
You must own the materialized view to use <command>ALTER MATERIALIZED |
| 64 |
VIEW</command>. To change a materialized view's schema, you must also have |
| 65 |
<literal>CREATE</literal> privilege on the new schema. |
| 66 |
To alter the owner, you must be able to <literal>SET ROLE</literal> to the |
| 67 |
new owning role, and that role must have <literal>CREATE</literal> |
| 68 |
privilege on the materialized view's schema. |
| 69 |
(These restrictions enforce that altering |
| 70 |
the owner doesn't do anything you couldn't do by dropping and recreating the |
| 71 |
materialized view. However, a superuser can alter ownership of any view |
| 72 |
anyway.) |
| 73 |
</para> |
| 74 |
|
| 75 |
<para> |
| 76 |
The statement subforms and actions available for |
| 77 |
<command>ALTER MATERIALIZED VIEW</command> are a subset of those available |
| 78 |
for <command>ALTER TABLE</command>, and have the same meaning when used for |
| 79 |
materialized views. See the descriptions for |
| 80 |
<link linkend="sql-altertable"><command>ALTER TABLE</command></link> |
| 81 |
for details. |
| 82 |
</para> |
| 83 |
</refsect1> |
| 84 |
|
| 85 |
<refsect1> |
| 86 |
<title>Parameters</title> |
| 87 |
|
| 88 |
<variablelist> |
| 89 |
|
| 90 |
<varlistentry> |
| 91 |
<term><replaceable class="parameter">name</replaceable></term> |
| 92 |
<listitem> |
| 93 |
<para> |
| 94 |
The name (optionally schema-qualified) of an existing materialized view. |
| 95 |
</para> |
| 96 |
</listitem> |
| 97 |
</varlistentry> |
| 98 |
|
| 99 |
<varlistentry> |
| 100 |
<term><replaceable class="parameter">column_name</replaceable></term> |
| 101 |
<listitem> |
| 102 |
<para> |
| 103 |
Name of an existing column. |
| 104 |
</para> |
| 105 |
</listitem> |
| 106 |
</varlistentry> |
| 107 |
|
| 108 |
<varlistentry> |
| 109 |
<term><replaceable class="parameter">extension_name</replaceable></term> |
| 110 |
<listitem> |
| 111 |
<para> |
| 112 |
The name of the extension that the materialized view is to depend on (or no longer |
| 113 |
dependent on, if <literal>NO</literal> is specified). A materialized view |
| 114 |
that's marked as dependent on an extension is automatically dropped when |
| 115 |
the extension is dropped. |
| 116 |
</para> |
| 117 |
</listitem> |
| 118 |
</varlistentry> |
| 119 |
|
| 120 |
<varlistentry> |
| 121 |
<term><replaceable class="parameter">new_column_name</replaceable></term> |
| 122 |
<listitem> |
| 123 |
<para> |
| 124 |
New name for an existing column. |
| 125 |
</para> |
| 126 |
</listitem> |
| 127 |
</varlistentry> |
| 128 |
|
| 129 |
<varlistentry> |
| 130 |
<term><replaceable class="parameter">new_owner</replaceable></term> |
| 131 |
<listitem> |
| 132 |
<para> |
| 133 |
The user name of the new owner of the materialized view. |
| 134 |
</para> |
| 135 |
</listitem> |
| 136 |
</varlistentry> |
| 137 |
|
| 138 |
<varlistentry> |
| 139 |
<term><replaceable class="parameter">new_name</replaceable></term> |
| 140 |
<listitem> |
| 141 |
<para> |
| 142 |
The new name for the materialized view. |
| 143 |
</para> |
| 144 |
</listitem> |
| 145 |
</varlistentry> |
| 146 |
|
| 147 |
<varlistentry> |
| 148 |
<term><replaceable class="parameter">new_schema</replaceable></term> |
| 149 |
<listitem> |
| 150 |
<para> |
| 151 |
The new schema for the materialized view. |
| 152 |
</para> |
| 153 |
</listitem> |
| 154 |
</varlistentry> |
| 155 |
</variablelist> |
| 156 |
</refsect1> |
| 157 |
|
| 158 |
<refsect1> |
| 159 |
<title>Examples</title> |
| 160 |
|
| 161 |
<para> |
| 162 |
To rename the materialized view <literal>foo</literal> to |
| 163 |
<literal>bar</literal>: |
| 164 |
<programlisting> |
| 165 |
ALTER MATERIALIZED VIEW foo RENAME TO bar; |
| 166 |
</programlisting></para> |
| 167 |
</refsect1> |
| 168 |
|
| 169 |
<refsect1> |
| 170 |
<title>Compatibility</title> |
| 171 |
|
| 172 |
<para> |
| 173 |
<command>ALTER MATERIALIZED VIEW</command> is a |
| 174 |
<productname>PostgreSQL</productname> extension. |
| 175 |
</para> |
| 176 |
</refsect1> |
| 177 |
|
| 178 |
<refsect1> |
| 179 |
<title>See Also</title> |
| 180 |
|
| 181 |
<simplelist type="inline"> |
| 182 |
<member><xref linkend="sql-creatematerializedview"/></member> |
| 183 |
<member><xref linkend="sql-dropmaterializedview"/></member> |
| 184 |
<member><xref linkend="sql-refreshmaterializedview"/></member> |
| 185 |
</simplelist> |
| 186 |
</refsect1> |
| 187 |
</refentry> |