]> granicus.if.org Git - postgresql/blob - doc/src/sgml/ref/alter_aggregate.sgml
Add support for piping COPY to/from an external program.
[postgresql] / doc / src / sgml / ref / alter_aggregate.sgml
1 <!--
2 doc/src/sgml/ref/alter_aggregate.sgml
3 PostgreSQL documentation
4 -->
5
6 <refentry id="SQL-ALTERAGGREGATE">
7  <refmeta>
8   <refentrytitle>ALTER AGGREGATE</refentrytitle>
9   <manvolnum>7</manvolnum>
10   <refmiscinfo>SQL - Language Statements</refmiscinfo>
11  </refmeta>
12
13  <refnamediv>
14   <refname>ALTER AGGREGATE</refname>
15   <refpurpose>change the definition of an aggregate function</refpurpose>
16  </refnamediv>
17
18  <indexterm zone="sql-alteraggregate">
19   <primary>ALTER AGGREGATE</primary>
20  </indexterm>
21
22  <refsynopsisdiv>
23 <synopsis>
24 ALTER AGGREGATE <replaceable>name</replaceable> ( <replaceable>argtype</replaceable> [ , ... ] ) RENAME TO <replaceable>new_name</replaceable>
25 ALTER AGGREGATE <replaceable>name</replaceable> ( <replaceable>argtype</replaceable> [ , ... ] ) OWNER TO <replaceable>new_owner</replaceable>
26 ALTER AGGREGATE <replaceable>name</replaceable> ( <replaceable>argtype</replaceable> [ , ... ] ) SET SCHEMA <replaceable>new_schema</replaceable>
27 </synopsis>
28  </refsynopsisdiv>
29
30  <refsect1>
31   <title>Description</title>
32
33   <para>
34    <command>ALTER AGGREGATE</command> changes the definition of an
35    aggregate function.
36   </para>
37
38   <para>
39    You must own the aggregate function to use <command>ALTER AGGREGATE</>.
40    To change the schema of an aggregate function, you must also have
41    <literal>CREATE</literal> privilege on the new schema.
42    To alter the owner, you must also be a direct or indirect member of the new
43    owning role, and that role must have <literal>CREATE</literal> privilege on
44    the aggregate function's schema.  (These restrictions enforce that altering
45    the owner doesn't do anything you couldn't do by dropping and recreating
46    the aggregate function.  However, a superuser can alter ownership of any
47    aggregate function anyway.)
48   </para>
49  </refsect1>
50
51  <refsect1>
52   <title>Parameters</title>
53
54   <variablelist>
55    <varlistentry>
56     <term><replaceable class="parameter">name</replaceable></term>
57     <listitem>
58      <para>
59       The name (optionally schema-qualified) of an existing aggregate function.
60      </para>
61     </listitem>
62    </varlistentry>
63
64    <varlistentry>
65     <term><replaceable class="parameter">argtype</replaceable></term>
66     <listitem>
67      <para>
68       An input data type on which the aggregate function operates.
69       To reference a zero-argument aggregate function, write <literal>*</>
70       in place of the list of input data types.
71      </para>
72     </listitem>
73    </varlistentry>
74
75    <varlistentry>
76     <term><replaceable class="parameter">new_name</replaceable></term>
77     <listitem>
78      <para>
79       The new name of the aggregate function.
80      </para>
81     </listitem>
82    </varlistentry>
83
84    <varlistentry>
85     <term><replaceable class="parameter">new_owner</replaceable></term>
86     <listitem>
87      <para>
88       The new owner of the aggregate function.
89      </para>
90     </listitem>
91    </varlistentry>
92
93    <varlistentry>
94     <term><replaceable class="parameter">new_schema</replaceable></term>
95     <listitem>
96      <para>
97       The new schema for the aggregate function.
98      </para>
99     </listitem>
100    </varlistentry>
101   </variablelist>
102  </refsect1>
103
104  <refsect1>
105   <title>Examples</title>
106
107   <para>
108    To rename the aggregate function <literal>myavg</literal> for type
109    <type>integer</type> to <literal>my_average</literal>:
110 <programlisting>
111 ALTER AGGREGATE myavg(integer) RENAME TO my_average;
112 </programlisting>
113   </para>
114
115   <para>
116    To change the owner of the aggregate function <literal>myavg</literal> for type
117    <type>integer</type> to <literal>joe</literal>:
118 <programlisting>
119 ALTER AGGREGATE myavg(integer) OWNER TO joe;
120 </programlisting>
121   </para>
122
123   <para>
124    To move the aggregate function <literal>myavg</literal> for type
125    <type>integer</type> into schema <literal>myschema</literal>:
126 <programlisting>
127 ALTER AGGREGATE myavg(integer) SET SCHEMA myschema;
128 </programlisting></para>
129  </refsect1>
130
131  <refsect1>
132   <title>Compatibility</title>
133
134   <para>
135    There is no <command>ALTER AGGREGATE</command> statement in the SQL
136    standard.
137   </para>
138  </refsect1>
139
140  <refsect1>
141   <title>See Also</title>
142
143   <simplelist type="inline">
144    <member><xref linkend="sql-createaggregate"></member>
145    <member><xref linkend="sql-dropaggregate"></member>
146   </simplelist>
147  </refsect1>
148 </refentry>