2 .\" Title: ALTER AGGREGATE
3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "ALTER AGGREGATE" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 ALTER_AGGREGATE \- change the definition of an aggregate function
35 ALTER AGGREGATE \fIname\fR ( \fIaggregate_signature\fR ) RENAME TO \fInew_name\fR
36 ALTER AGGREGATE \fIname\fR ( \fIaggregate_signature\fR )
37 OWNER TO { \fInew_owner\fR | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
38 ALTER AGGREGATE \fIname\fR ( \fIaggregate_signature\fR ) SET SCHEMA \fInew_schema\fR
40 where \fIaggregate_signature\fR is:
43 [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [ , \&.\&.\&. ] |
44 [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [ , \&.\&.\&. ] ] ORDER BY [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [ , \&.\&.\&. ]
49 changes the definition of an aggregate function\&.
51 You must own the aggregate function to use
52 \fBALTER AGGREGATE\fR\&. To change the schema of an aggregate function, you must also have
54 privilege on the new schema\&. To alter the owner, you must be able to
56 to the new owning role, and that role must have
58 privilege on the aggregate function\*(Aqs schema\&. (These restrictions enforce that altering the owner doesn\*(Aqt do anything you couldn\*(Aqt do by dropping and recreating the aggregate function\&. However, a superuser can alter ownership of any aggregate function anyway\&.)
63 The name (optionally schema\-qualified) of an existing aggregate function\&.
68 The mode of an argument:
71 VARIADIC\&. If omitted, the default is
77 The name of an argument\&. Note that
79 does not actually pay any attention to argument names, since only the argument data types are needed to determine the aggregate function\*(Aqs identity\&.
84 An input data type on which the aggregate function operates\&. To reference a zero\-argument aggregate function, write
86 in place of the list of argument specifications\&. To reference an ordered\-set aggregate function, write
88 between the direct and aggregated argument specifications\&.
93 The new name of the aggregate function\&.
98 The new owner of the aggregate function\&.
103 The new schema for the aggregate function\&.
107 The recommended syntax for referencing an ordered\-set aggregate is to write
109 between the direct and aggregated argument specifications, in the same style as in
110 \fBCREATE AGGREGATE\fR\&. However, it will also work to omit
112 and just run the direct and aggregated argument specifications into a single list\&. In this abbreviated form, if
114 was used in both the direct and aggregated argument lists, write
119 To rename the aggregate function
130 ALTER AGGREGATE myavg(integer) RENAME TO my_average;
136 To change the owner of the aggregate function
147 ALTER AGGREGATE myavg(integer) OWNER TO joe;
153 To move the ordered\-set aggregate
155 with direct argument of type
157 and aggregated argument of type
166 ALTER AGGREGATE mypercentile(float8 ORDER BY integer) SET SCHEMA myschema;
178 ALTER AGGREGATE mypercentile(float8, integer) SET SCHEMA myschema;
186 \fBALTER AGGREGATE\fR
187 statement in the SQL standard\&.
189 CREATE AGGREGATE (\fBCREATE_AGGREGATE\fR(7)), DROP AGGREGATE (\fBDROP_AGGREGATE\fR(7))