Synopsis

Use the DROP AGGREGATE statement to remove an aggregate.

Syntax

drop_aggregate ::= DROP AGGREGATE [ IF EXISTS ] 
                   { aggregate_name ( aggregate_signature ) } 
                   [ , ... ] [ CASCADE | RESTRICT ]

aggregate_signature ::= * | aggregate_arg [ , ... ]
                        | [ aggregate_arg [ , ... ] ] ORDER BY 
                          aggregate_arg [ , ... ]

drop_aggregate

DROPAGGREGATEIFEXISTS,aggregate_name(aggregate_signature)CASCADERESTRICT

aggregate_signature

*,aggregate_arg,aggregate_argORDERBY,aggregate_arg

Semantics

See the semantics of each option in the [PostgreSQL docs][postgresql-docs-drop-aggregate].

Examples

Basic example.

yugabyte=# CREATE AGGREGATE newcnt(*) (
             sfunc = int8inc,
             stype = int8,
             initcond = '0',
             parallel = safe
           );
yugabyte=# DROP AGGREGATE newcnt(*);

IF EXISTS example.

yugabyte=# DROP AGGREGATE IF EXISTS newcnt(*);
yugabyte=# CREATE AGGREGATE newcnt(*) (
             sfunc = int8inc,
             stype = int8,
             initcond = '0',
             parallel = safe
           );
yugabyte=# DROP AGGREGATE IF EXISTS newcnt(*);

CASCADE and RESTRICT example.

yugabyte=# CREATE AGGREGATE newcnt(*) (
             sfunc = int8inc,
             stype = int8,
             initcond = '0',
             parallel = safe
           );
yugabyte=# CREATE VIEW cascade_view AS
             SELECT newcnt(*) FROM pg_aggregate;
yugabyte=# -- The following should error:
yugabyte=# DROP AGGREGATE newcnt(*) RESTRICT;
yugabyte=# -- The following should error:
yugabyte=# DROP AGGREGATE newcnt(*);
yugabyte=# DROP AGGREGATE newcnt(*) CASCADE;

See also