]> begriffs open source - ai-pg/blob - full-docs/man7/ALTER_AGGREGATE.7
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / man7 / ALTER_AGGREGATE.7
1 '\" t
2 .\"     Title: ALTER AGGREGATE
3 .\"    Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5 .\"      Date: 2025
6 .\"    Manual: PostgreSQL 18.0 Documentation
7 .\"    Source: PostgreSQL 18.0
8 .\"  Language: English
9 .\"
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 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 ALTER_AGGREGATE \- change the definition of an aggregate function
32 .SH "SYNOPSIS"
33 .sp
34 .nf
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
39
40 where \fIaggregate_signature\fR is:
41
42 * |
43 [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [ , \&.\&.\&. ] |
44 [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [ , \&.\&.\&. ] ] ORDER BY [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [ , \&.\&.\&. ]
45 .fi
46 .SH "DESCRIPTION"
47 .PP
48 \fBALTER AGGREGATE\fR
49 changes the definition of an aggregate function\&.
50 .PP
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
53 CREATE
54 privilege on the new schema\&. To alter the owner, you must be able to
55 SET ROLE
56 to the new owning role, and that role must have
57 CREATE
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\&.)
59 .SH "PARAMETERS"
60 .PP
61 \fIname\fR
62 .RS 4
63 The name (optionally schema\-qualified) of an existing aggregate function\&.
64 .RE
65 .PP
66 \fIargmode\fR
67 .RS 4
68 The mode of an argument:
69 IN
70 or
71 VARIADIC\&. If omitted, the default is
72 IN\&.
73 .RE
74 .PP
75 \fIargname\fR
76 .RS 4
77 The name of an argument\&. Note that
78 \fBALTER AGGREGATE\fR
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\&.
80 .RE
81 .PP
82 \fIargtype\fR
83 .RS 4
84 An input data type on which the aggregate function operates\&. To reference a zero\-argument aggregate function, write
85 *
86 in place of the list of argument specifications\&. To reference an ordered\-set aggregate function, write
87 ORDER BY
88 between the direct and aggregated argument specifications\&.
89 .RE
90 .PP
91 \fInew_name\fR
92 .RS 4
93 The new name of the aggregate function\&.
94 .RE
95 .PP
96 \fInew_owner\fR
97 .RS 4
98 The new owner of the aggregate function\&.
99 .RE
100 .PP
101 \fInew_schema\fR
102 .RS 4
103 The new schema for the aggregate function\&.
104 .RE
105 .SH "NOTES"
106 .PP
107 The recommended syntax for referencing an ordered\-set aggregate is to write
108 ORDER BY
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
111 ORDER BY
112 and just run the direct and aggregated argument specifications into a single list\&. In this abbreviated form, if
113 VARIADIC "any"
114 was used in both the direct and aggregated argument lists, write
115 VARIADIC "any"
116 only once\&.
117 .SH "EXAMPLES"
118 .PP
119 To rename the aggregate function
120 myavg
121 for type
122 integer
123 to
124 my_average:
125 .sp
126 .if n \{\
127 .RS 4
128 .\}
129 .nf
130 ALTER AGGREGATE myavg(integer) RENAME TO my_average;
131 .fi
132 .if n \{\
133 .RE
134 .\}
135 .PP
136 To change the owner of the aggregate function
137 myavg
138 for type
139 integer
140 to
141 joe:
142 .sp
143 .if n \{\
144 .RS 4
145 .\}
146 .nf
147 ALTER AGGREGATE myavg(integer) OWNER TO joe;
148 .fi
149 .if n \{\
150 .RE
151 .\}
152 .PP
153 To move the ordered\-set aggregate
154 mypercentile
155 with direct argument of type
156 float8
157 and aggregated argument of type
158 integer
159 into schema
160 myschema:
161 .sp
162 .if n \{\
163 .RS 4
164 .\}
165 .nf
166 ALTER AGGREGATE mypercentile(float8 ORDER BY integer) SET SCHEMA myschema;
167 .fi
168 .if n \{\
169 .RE
170 .\}
171 .sp
172 This will work too:
173 .sp
174 .if n \{\
175 .RS 4
176 .\}
177 .nf
178 ALTER AGGREGATE mypercentile(float8, integer) SET SCHEMA myschema;
179 .fi
180 .if n \{\
181 .RE
182 .\}
183 .SH "COMPATIBILITY"
184 .PP
185 There is no
186 \fBALTER AGGREGATE\fR
187 statement in the SQL standard\&.
188 .SH "SEE ALSO"
189 CREATE AGGREGATE (\fBCREATE_AGGREGATE\fR(7)), DROP AGGREGATE (\fBDROP_AGGREGATE\fR(7))