2 doc/src/sgml/ref/alter_view.sgml
3 PostgreSQL documentation
6 <refentry id="SQL-ALTERVIEW">
8 <refentrytitle>ALTER VIEW</refentrytitle>
9 <manvolnum>7</manvolnum>
10 <refmiscinfo>SQL - Language Statements</refmiscinfo>
14 <refname>ALTER VIEW</refname>
15 <refpurpose>change the definition of a view</refpurpose>
18 <indexterm zone="sql-alterview">
19 <primary>ALTER VIEW</primary>
24 ALTER VIEW <replaceable class="parameter">name</replaceable> ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> SET DEFAULT <replaceable class="PARAMETER">expression</replaceable>
25 ALTER VIEW <replaceable class="parameter">name</replaceable> ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> DROP DEFAULT
26 ALTER VIEW <replaceable class="parameter">name</replaceable> OWNER TO <replaceable class="PARAMETER">new_owner</replaceable>
27 ALTER VIEW <replaceable class="parameter">name</replaceable> RENAME TO <replaceable class="parameter">new_name</replaceable>
28 ALTER VIEW <replaceable class="parameter">name</replaceable> SET SCHEMA <replaceable class="parameter">new_schema</replaceable>
33 <title>Description</title>
36 <command>ALTER VIEW</command> changes various auxiliary properties
37 of a view. (If you want to modify the view's defining query,
38 use <command>CREATE OR REPLACE VIEW</>.)
42 You must own the view to use <command>ALTER VIEW</>.
43 To change a view's schema, you must also have <literal>CREATE</>
44 privilege on the new schema.
45 To alter the owner, you must also be a direct or indirect member of the new
46 owning role, and that role must have <literal>CREATE</literal> privilege on
47 the view's schema. (These restrictions enforce that altering the owner
48 doesn't do anything you couldn't do by dropping and recreating the view.
49 However, a superuser can alter ownership of any view anyway.)
54 <title>Parameters</title>
58 <term><replaceable class="parameter">name</replaceable></term>
61 The name (optionally schema-qualified) of an existing view.
67 <term><literal>SET</literal>/<literal>DROP DEFAULT</literal></term>
70 These forms set or remove the default value for a column.
71 A default value associated with a view column is
72 inserted into <command>INSERT</> statements on the view before
73 the view's <literal>ON INSERT</literal> rule is applied, if
74 the <command>INSERT</> does not specify a value for the column.
80 <term><replaceable class="PARAMETER">new_owner</replaceable></term>
83 The user name of the new owner of the view.
89 <term><replaceable class="parameter">new_name</replaceable></term>
92 The new name for the view.
98 <term><replaceable class="parameter">new_schema</replaceable></term>
101 The new schema for the view.
112 For historical reasons, <command>ALTER TABLE</command> can be used with
113 views too; but the only variants of <command>ALTER TABLE</command>
114 that are allowed with views are equivalent to the ones shown above.
119 <title>Examples</title>
122 To rename the view <literal>foo</literal> to
123 <literal>bar</literal>:
125 ALTER VIEW foo RENAME TO bar;
126 </programlisting></para>
130 <title>Compatibility</title>
133 <command>ALTER VIEW</command> is a <productname>PostgreSQL</>
134 extension of the SQL standard.
139 <title>See Also</title>
141 <simplelist type="inline">
142 <member><xref linkend="sql-createview"></member>
143 <member><xref linkend="sql-dropview"></member>