3 PostgreSQL documentation
6 <refentry id=
"SQL-ALTERVIEW">
8 <refentrytitle id=
"SQL-ALTERVIEW-TITLE">ALTER VIEW
</refentrytitle>
9 <refmiscinfo>SQL - Language Statements
</refmiscinfo>
13 <refname>ALTER VIEW
</refname>
14 <refpurpose>change the definition of a view
</refpurpose>
17 <indexterm zone=
"sql-alterview">
18 <primary>ALTER VIEW
</primary>
23 ALTER VIEW
<replaceable class=
"parameter">name
</replaceable> ALTER [ COLUMN ]
<replaceable class=
"PARAMETER">column
</replaceable> SET DEFAULT
<replaceable class=
"PARAMETER">expression
</replaceable>
24 ALTER VIEW
<replaceable class=
"parameter">name
</replaceable> ALTER [ COLUMN ]
<replaceable class=
"PARAMETER">column
</replaceable> DROP DEFAULT
25 ALTER VIEW
<replaceable class=
"parameter">name
</replaceable> OWNER TO
<replaceable class=
"PARAMETER">new_owner
</replaceable>
26 ALTER VIEW
<replaceable class=
"parameter">name
</replaceable> RENAME TO
<replaceable class=
"parameter">new_name
</replaceable>
27 ALTER VIEW
<replaceable class=
"parameter">name
</replaceable> SET SCHEMA
<replaceable class=
"parameter">new_schema
</replaceable>
32 <title>Description
</title>
35 <command>ALTER VIEW
</command> changes various auxiliary properties
36 of a view. (If you want to modify the view's defining query,
37 use
<command>CREATE OR REPLACE VIEW<
/>.)
41 You must own the view to use
<command>ALTER VIEW<
/>.
42 To change a view's schema, you must also have
<literal>CREATE<
/>
43 privilege on the new schema.
44 To alter the owner, you must also be a direct or indirect member of the new
45 owning role, and that role must have
<literal>CREATE
</literal> privilege on
46 the view's schema. (These restrictions enforce that altering the owner
47 doesn't do anything you couldn't do by dropping and recreating the view.
48 However, a superuser can alter ownership of any view anyway.)
53 <title>Parameters
</title>
57 <term><replaceable class=
"parameter">name
</replaceable></term>
60 The name (optionally schema-qualified) of an existing view.
66 <term><literal>SET
</literal>/
<literal>DROP DEFAULT
</literal></term>
69 These forms set or remove the default value for a column.
70 A default value associated with a view column is
71 inserted into
<command>INSERT<
/> statements on the view before
72 the view's
<literal>ON INSERT
</literal> rule is applied, if
73 the
<command>INSERT<
/> does not specify a value for the column.
79 <term><replaceable class=
"PARAMETER">new_owner
</replaceable></term>
82 The user name of the new owner of the view.
88 <term><replaceable class=
"parameter">new_name
</replaceable></term>
91 The new name for the view.
97 <term><replaceable class=
"parameter">new_schema
</replaceable></term>
100 The new schema for the view.
111 For historical reasons,
<command>ALTER TABLE
</command> can be used with
112 views too; but the only variants of
<command>ALTER TABLE
</command>
113 that are allowed with views are equivalent to the ones shown above.
118 <title>Examples
</title>
121 To rename the view
<literal>foo
</literal> to
122 <literal>bar
</literal>:
124 ALTER VIEW foo RENAME TO bar;
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" endterm=
"sql-createview-title"></member>
143 <member><xref linkend=
"sql-dropview" endterm=
"sql-dropview-title"></member>