1ALTER AGGREGATE(7) PostgreSQL 15.4 Documentation ALTER AGGREGATE(7)
2
3
4
6 ALTER_AGGREGATE - change the definition of an aggregate function
7
9 ALTER AGGREGATE name ( aggregate_signature ) RENAME TO new_name
10 ALTER AGGREGATE name ( aggregate_signature )
11 OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
12 ALTER AGGREGATE name ( aggregate_signature ) SET SCHEMA new_schema
13
14 where aggregate_signature is:
15
16 * |
17 [ argmode ] [ argname ] argtype [ , ... ] |
18 [ [ argmode ] [ argname ] argtype [ , ... ] ] ORDER BY [ argmode ] [ argname ] argtype [ , ... ]
19
21 ALTER AGGREGATE changes the definition of an aggregate function.
22
23 You must own the aggregate function to use ALTER AGGREGATE. To change
24 the schema of an aggregate function, you must also have CREATE
25 privilege on the new schema. To alter the owner, you must also be a
26 direct or indirect member of the new owning role, and that role must
27 have CREATE privilege on the aggregate function's schema. (These
28 restrictions enforce that altering the owner doesn't do anything you
29 couldn't do by dropping and recreating the aggregate function. However,
30 a superuser can alter ownership of any aggregate function anyway.)
31
33 name
34 The name (optionally schema-qualified) of an existing aggregate
35 function.
36
37 argmode
38 The mode of an argument: IN or VARIADIC. If omitted, the default is
39 IN.
40
41 argname
42 The name of an argument. Note that ALTER AGGREGATE does not
43 actually pay any attention to argument names, since only the
44 argument data types are needed to determine the aggregate
45 function's identity.
46
47 argtype
48 An input data type on which the aggregate function operates. To
49 reference a zero-argument aggregate function, write * in place of
50 the list of argument specifications. To reference an ordered-set
51 aggregate function, write ORDER BY between the direct and
52 aggregated argument specifications.
53
54 new_name
55 The new name of the aggregate function.
56
57 new_owner
58 The new owner of the aggregate function.
59
60 new_schema
61 The new schema for the aggregate function.
62
64 The recommended syntax for referencing an ordered-set aggregate is to
65 write ORDER BY between the direct and aggregated argument
66 specifications, in the same style as in CREATE AGGREGATE. However, it
67 will also work to omit ORDER BY and just run the direct and aggregated
68 argument specifications into a single list. In this abbreviated form,
69 if VARIADIC "any" was used in both the direct and aggregated argument
70 lists, write VARIADIC "any" only once.
71
73 To rename the aggregate function myavg for type integer to my_average:
74
75 ALTER AGGREGATE myavg(integer) RENAME TO my_average;
76
77 To change the owner of the aggregate function myavg for type integer to
78 joe:
79
80 ALTER AGGREGATE myavg(integer) OWNER TO joe;
81
82 To move the ordered-set aggregate mypercentile with direct argument of
83 type float8 and aggregated argument of type integer into schema
84 myschema:
85
86 ALTER AGGREGATE mypercentile(float8 ORDER BY integer) SET SCHEMA myschema;
87
88 This will work too:
89
90 ALTER AGGREGATE mypercentile(float8, integer) SET SCHEMA myschema;
91
93 There is no ALTER AGGREGATE statement in the SQL standard.
94
96 CREATE AGGREGATE (CREATE_AGGREGATE(7)), DROP AGGREGATE
97 (DROP_AGGREGATE(7))
98
99
100
101PostgreSQL 15.4 2023 ALTER AGGREGATE(7)