]> begriffs open source - ai-pg/blob - full-docs/txt/sql-alteraggregate.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / sql-alteraggregate.txt
1
2 ALTER AGGREGATE
3
4    ALTER AGGREGATE — change the definition of an aggregate function
5
6 Synopsis
7
8 ALTER AGGREGATE name ( aggregate_signature ) RENAME TO new_name
9 ALTER AGGREGATE name ( aggregate_signature )
10                 OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USE
11 R }
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 ] a
19 rgtype [ , ... ]
20
21 Description
22
23    ALTER AGGREGATE changes the definition of an aggregate function.
24
25    You must own the aggregate function to use ALTER AGGREGATE. To change
26    the schema of an aggregate function, you must also have CREATE
27    privilege on the new schema. To alter the owner, you must be able to
28    SET ROLE to the new owning role, and that role must have CREATE
29    privilege on the aggregate function's schema. (These restrictions
30    enforce that altering the owner doesn't do anything you couldn't do by
31    dropping and recreating the aggregate function. However, a superuser
32    can alter ownership of any aggregate function anyway.)
33
34 Parameters
35
36    name
37           The name (optionally schema-qualified) of an existing aggregate
38           function.
39
40    argmode
41           The mode of an argument: IN or VARIADIC. If omitted, the default
42           is IN.
43
44    argname
45           The name of an argument. Note that ALTER AGGREGATE does not
46           actually pay any attention to argument names, since only the
47           argument data types are needed to determine the aggregate
48           function's identity.
49
50    argtype
51           An input data type on which the aggregate function operates. To
52           reference a zero-argument aggregate function, write * in place
53           of the list of argument specifications. To reference an
54           ordered-set aggregate function, write ORDER BY between the
55           direct and aggregated argument specifications.
56
57    new_name
58           The new name of the aggregate function.
59
60    new_owner
61           The new owner of the aggregate function.
62
63    new_schema
64           The new schema for the aggregate function.
65
66 Notes
67
68    The recommended syntax for referencing an ordered-set aggregate is to
69    write ORDER BY between the direct and aggregated argument
70    specifications, in the same style as in CREATE AGGREGATE. However, it
71    will also work to omit ORDER BY and just run the direct and aggregated
72    argument specifications into a single list. In this abbreviated form,
73    if VARIADIC "any" was used in both the direct and aggregated argument
74    lists, write VARIADIC "any" only once.
75
76 Examples
77
78    To rename the aggregate function myavg for type integer to my_average:
79 ALTER AGGREGATE myavg(integer) RENAME TO my_average;
80
81    To change the owner of the aggregate function myavg for type integer to
82    joe:
83 ALTER AGGREGATE myavg(integer) OWNER TO joe;
84
85    To move the ordered-set aggregate mypercentile with direct argument of
86    type float8 and aggregated argument of type integer into schema
87    myschema:
88 ALTER AGGREGATE mypercentile(float8 ORDER BY integer) SET SCHEMA myschema;
89
90    This will work too:
91 ALTER AGGREGATE mypercentile(float8, integer) SET SCHEMA myschema;
92
93 Compatibility
94
95    There is no ALTER AGGREGATE statement in the SQL standard.
96
97 See Also
98
99    CREATE AGGREGATE, DROP AGGREGATE