Make LC_COLLATE and LC_CTYPE database-level settings. Collation and
[PostgreSQL.git] / doc / src / sgml / ref / alter_view.sgml
blob04f7f03030f13761a88797b0ba105798d7393737
1 <!--
2 $PostgreSQL$
3 PostgreSQL documentation
4 -->
6 <refentry id="SQL-ALTERVIEW">
7 <refmeta>
8 <refentrytitle id="SQL-ALTERVIEW-TITLE">ALTER VIEW</refentrytitle>
9 <refmiscinfo>SQL - Language Statements</refmiscinfo>
10 </refmeta>
12 <refnamediv>
13 <refname>ALTER VIEW</refname>
14 <refpurpose>change the definition of a view</refpurpose>
15 </refnamediv>
17 <indexterm zone="sql-alterview">
18 <primary>ALTER VIEW</primary>
19 </indexterm>
21 <refsynopsisdiv>
22 <synopsis>
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>
28 </synopsis>
29 </refsynopsisdiv>
31 <refsect1>
32 <title>Description</title>
34 <para>
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</>.)
38 </para>
40 <para>
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.)
49 </para>
50 </refsect1>
52 <refsect1>
53 <title>Parameters</title>
55 <variablelist>
56 <varlistentry>
57 <term><replaceable class="parameter">name</replaceable></term>
58 <listitem>
59 <para>
60 The name (optionally schema-qualified) of an existing view.
61 </para>
62 </listitem>
63 </varlistentry>
65 <varlistentry>
66 <term><literal>SET</literal>/<literal>DROP DEFAULT</literal></term>
67 <listitem>
68 <para>
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.
74 </para>
75 </listitem>
76 </varlistentry>
78 <varlistentry>
79 <term><replaceable class="PARAMETER">new_owner</replaceable></term>
80 <listitem>
81 <para>
82 The user name of the new owner of the view.
83 </para>
84 </listitem>
85 </varlistentry>
87 <varlistentry>
88 <term><replaceable class="parameter">new_name</replaceable></term>
89 <listitem>
90 <para>
91 The new name for the view.
92 </para>
93 </listitem>
94 </varlistentry>
96 <varlistentry>
97 <term><replaceable class="parameter">new_schema</replaceable></term>
98 <listitem>
99 <para>
100 The new schema for the view.
101 </para>
102 </listitem>
103 </varlistentry>
104 </variablelist>
105 </refsect1>
107 <refsect1>
108 <title>Notes</title>
110 <para>
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.
114 </para>
115 </refsect1>
117 <refsect1>
118 <title>Examples</title>
120 <para>
121 To rename the view <literal>foo</literal> to
122 <literal>bar</literal>:
123 <programlisting>
124 ALTER VIEW foo RENAME TO bar;
125 </programlisting>
126 </para>
127 </refsect1>
129 <refsect1>
130 <title>Compatibility</title>
132 <para>
133 <command>ALTER VIEW</command> is a <productname>PostgreSQL</>
134 extension of the SQL standard.
135 </para>
136 </refsect1>
138 <refsect1>
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>
144 </simplelist>
145 </refsect1>
146 </refentry>