Updated on 2024-06-03 GMT+08:00

DROP AGGREGATE

Description

Deletes an aggregate function.

Precautions

DROP AGGREGATE deletes an existing aggregate function. Only the owner of the aggregate function can run this command.

Syntax

DROP AGGREGATE [ IF EXISTS ] name ( argtype [ , ... ] ) [ CASCADE | RESTRICT ];

Parameters

  • IF EXISTS

    If the specified aggregate function does not exist, a NOTICE prompt is generated, but no error is generated.

  • name

    Name of an existing aggregate function (optionally schema-qualified).

  • argtype

    Input data type of the aggregate function. To reference a zero-parameter aggregate function, replace the input data type list using *.

  • CASCADE

    Cascadingly deletes objects that depend on the aggregate function.

  • RESTRICT

    Refuses to delete the aggregate function if any objects depend on it. This is a default processing.

Examples

-- Create a user-defined function.
gaussdb=# CREATE OR REPLACE FUNCTION int_add(int,int)
	RETURNS int AS $BODY$
DECLARE
BEGIN
	RETURN $1 + $2;
END;
$BODY$ language plpgsql;

-- Create an aggregate function.
gaussdb=# CREATE AGGREGATE myavg (int)
(
    sfunc = int_add,
    stype = int,
    initcond = '0'
);

-- Delete the aggregate function myavg of the int type.
gaussdb=# DROP AGGREGATE myavg(int);

-- Delete the user-defined function.
gaussdb=# DROP FUNCTION int_add(int,int);

Helpful Links

ALTER AGGREGATE and CREATE AGGREGATE

Compatibility

The SQL standard does not provide the DROP AGGREGATE statement.