DROP AGGREGATE

Synopsis

Use the DROP AGGREGATE statement to remove an aggregate.

Syntax

  1. drop_aggregate ::= DROP AGGREGATE [ IF EXISTS ]
  2. { aggregate_name ( aggregate_signature ) }
  3. [ , ... ] [ CASCADE | RESTRICT ]
  4. aggregate_signature ::= * | aggregate_arg [ , ... ]
  5. | [ aggregate_arg [ , ... ] ] ORDER BY
  6. aggregate_arg [ , ... ]

drop_aggregate

DROP AGGREGATE - 图1

aggregate_signature

DROP AGGREGATE - 图2

Semantics

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

Examples

Basic example.

  1. yugabyte=# CREATE AGGREGATE newcnt(*) (
  2. sfunc = int8inc,
  3. stype = int8,
  4. initcond = '0',
  5. parallel = safe
  6. );
  7. yugabyte=# DROP AGGREGATE newcnt(*);

IF EXISTS example.

  1. yugabyte=# DROP AGGREGATE IF EXISTS newcnt(*);
  2. yugabyte=# CREATE AGGREGATE newcnt(*) (
  3. sfunc = int8inc,
  4. stype = int8,
  5. initcond = '0',
  6. parallel = safe
  7. );
  8. yugabyte=# DROP AGGREGATE IF EXISTS newcnt(*);

CASCADE and RESTRICT example.

  1. yugabyte=# CREATE AGGREGATE newcnt(*) (
  2. sfunc = int8inc,
  3. stype = int8,
  4. initcond = '0',
  5. parallel = safe
  6. );
  7. yugabyte=# CREATE VIEW cascade_view AS
  8. SELECT newcnt(*) FROM pg_aggregate;
  9. yugabyte=# -- The following should error:
  10. yugabyte=# DROP AGGREGATE newcnt(*) RESTRICT;
  11. yugabyte=# -- The following should error:
  12. yugabyte=# DROP AGGREGATE newcnt(*);
  13. yugabyte=# DROP AGGREGATE newcnt(*) CASCADE;

See also