]> granicus.if.org Git - postgresql/blob - doc/src/sgml/ref/alter_view.sgml
Create a "sort support" interface API for faster sorting.
[postgresql] / doc / src / sgml / ref / alter_view.sgml
1 <!--
2 doc/src/sgml/ref/alter_view.sgml
3 PostgreSQL documentation
4 -->
5
6 <refentry id="SQL-ALTERVIEW">
7  <refmeta>
8   <refentrytitle>ALTER VIEW</refentrytitle>
9   <manvolnum>7</manvolnum>
10   <refmiscinfo>SQL - Language Statements</refmiscinfo>
11  </refmeta>
12
13  <refnamediv>
14   <refname>ALTER VIEW</refname>
15   <refpurpose>change the definition of a view</refpurpose>
16  </refnamediv>
17
18  <indexterm zone="sql-alterview">
19   <primary>ALTER VIEW</primary>
20  </indexterm>
21
22  <refsynopsisdiv>
23 <synopsis>
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>
29 </synopsis>
30  </refsynopsisdiv>
31
32  <refsect1>
33   <title>Description</title>
34
35   <para>
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</>.)
39   </para>
40
41   <para>
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.)
50   </para>
51  </refsect1>
52
53  <refsect1>
54   <title>Parameters</title>
55
56   <variablelist>
57    <varlistentry>
58     <term><replaceable class="parameter">name</replaceable></term>
59     <listitem>
60      <para>
61       The name (optionally schema-qualified) of an existing view.
62      </para>
63     </listitem>
64    </varlistentry>
65
66    <varlistentry>
67     <term><literal>SET</literal>/<literal>DROP DEFAULT</literal></term>
68     <listitem>
69      <para>
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.
75      </para>
76     </listitem>
77    </varlistentry>
78
79    <varlistentry>
80     <term><replaceable class="PARAMETER">new_owner</replaceable></term>
81     <listitem>
82      <para>
83       The user name of the new owner of the view.
84      </para>
85     </listitem>
86    </varlistentry>
87
88    <varlistentry>
89     <term><replaceable class="parameter">new_name</replaceable></term>
90     <listitem>
91      <para>
92       The new name for the view.
93      </para>
94     </listitem>
95    </varlistentry>
96
97    <varlistentry>
98     <term><replaceable class="parameter">new_schema</replaceable></term>
99     <listitem>
100      <para>
101       The new schema for the view.
102      </para>
103     </listitem>
104    </varlistentry>
105   </variablelist>
106  </refsect1>
107
108  <refsect1>
109   <title>Notes</title>
110
111   <para>
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.
115   </para>
116  </refsect1>
117
118  <refsect1>
119   <title>Examples</title>
120
121   <para>
122    To rename the view <literal>foo</literal> to
123    <literal>bar</literal>:
124 <programlisting>
125 ALTER VIEW foo RENAME TO bar;
126 </programlisting></para>
127  </refsect1>
128
129  <refsect1>
130   <title>Compatibility</title>
131
132   <para>
133    <command>ALTER VIEW</command> is a <productname>PostgreSQL</>
134    extension of the SQL standard.
135   </para>
136  </refsect1>
137
138  <refsect1>
139   <title>See Also</title>
140
141   <simplelist type="inline">
142    <member><xref linkend="sql-createview"></member>
143    <member><xref linkend="sql-dropview"></member>
144   </simplelist>
145  </refsect1>
146 </refentry>