blob: af9dc6182bdfaff1075999581506db149ab89b94 [file] [log] [blame]
---
title: ALTER AGGREGATE
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
Changes the definition of an aggregate function.
## <a id="synop"></a>Synopsis
```pre
ALTER AGGREGATE <name> ( <type> [ , ... ] ) RENAME TO <new_name>
ALTER AGGREGATE <name> ( <type> [ , ... ] ) OWNER TO <new_owner>
ALTER AGGREGATE <name> ( <type> [ , ... ] ) SET SCHEMA <new_schema>
```
## <a id="desc"></a>Description
`ALTER AGGREGATE` changes the definition of an aggregate function.
You must own the aggregate function to use `ALTER AGGREGATE`. To change the schema of an aggregate function, you must also have `CREATE` privilege on the new schema. To alter the owner, you must also be a direct or indirect member of the new owning role, and that role must have `CREATE` privilege on the aggregate functions schema. (These restrictions enforce that altering the owner does not do anything you could not do by dropping and recreating the aggregate function. However, a superuser can alter ownership of any aggregate function anyway.)
## <a id="alteraggregate__section4"></a>Parameters
<dt> \<name\> </dt>
<dd>The name (optionally schema-qualified) of an existing aggregate function.</dd>
<dt> \<type\> </dt>
<dd>An input data type on which the aggregate function operates. To reference a zero-argument aggregate function, write \* in place of the list of input data types.</dd>
<dt> \<new\_name\> </dt>
<dd>The new name of the aggregate function.</dd>
<dt> \<new\_owner\> </dt>
<dd>The new owner of the aggregate function.</dd>
<dt> \<new\_schema\> </dt>
<dd>The new schema for the aggregate function.</dd>
## <a id="alteraggregate__section5"></a>Examples
To rename the aggregate function `myavg` for type `integer` to `my_average`:
```pre
ALTER AGGREGATE myavg(integer) RENAME TO my_average;
```
To change the owner of the aggregate function `myavg` for type `integer` to `joe`:
```pre
ALTER AGGREGATE myavg(integer) OWNER TO joe;
```
To move the aggregate function `myavg` for type `integer` into schema `myschema`:
```pre
ALTER AGGREGATE myavg(integer) SET SCHEMA myschema;
```
## <a id="compat"></a>Compatibility
There is no `ALTER AGGREGATE` statement in the SQL standard.
## <a id="see"></a>See Also
[CREATE AGGREGATE](CREATE-AGGREGATE.html), [DROP AGGREGATE](DROP-AGGREGATE.html)