DROP_AGGREGATE(7pg17)
π DROP_AGGREGATE π
okay so bestie, welcome to the DROP AGGREGATE page β this is the PostgreSQL 17.11 documentation, and we're about to learn how to yeet an aggregate function out of existence. no cap, it's actually so simple. πΈ
β¨ NAME β¨
DROP_AGGREGATE β remove an aggregate function ποΈ
π¦ SYNOPSIS π¦
DROP AGGREGATE [ IF EXISTS ] name ( aggregate_signature ) [, ...] [ CASCADE | RESTRICT ]
and like, aggregate_signature is defined as:
* |
[ argmode ] [ argname ] argtype [ , ... ] |
[ [ argmode ] [ argname ] argtype [ , ... ] ] ORDER BY [ argmode ] [ argname ] argtype [ , ... ]
that's it, that's the whole shape of it π
π DESCRIPTION π
DROP AGGREGATE removes an existing aggregate function. periodt. π
β οΈ heads up: to run this command, you have to be the owner of that aggregate function. no owner status, no drop. it's giving main character energy only for the owner, iykyk.
π PARAMETERS π
IF EXISTSβ don't throw an error if the aggregate literally doesn't exist. instead, a notice gets issued. so chill. π«Άnameβ the name of an existing aggregate function, optionally schema-qualified. like, whose is it, where does it live. πargmodeβ the mode of an argument, and it's eitherINorVARIADIC. if you justβ¦ don't say anything, the default isIN. slay. β¨argnameβ the name of an argument. but wait βDROP AGGREGATEdoes not actually pay any attention to argument names π because only the argument data types are needed to determine the aggregate function's identity. so yeah, names are just there being decorative fr fr.argtypeβ an input data type that the aggregate function operates on. and here's the fun part: to reference a zero-argument aggregate function, write*instead of the whole list of argument specifications. to reference an ordered-set aggregate function, writeORDER BYbetween the direct and aggregated argument specifications. iconic syntax behavior honestly πCASCADEβ automatically drop objects that depend on the aggregate function (like views using it), and then in turn all objects that depend on those objects. it's a whole chain reaction bestie (see Section 5.15). π₯RESTRICTβ refuse to drop the aggregate function if any objects depend on it. and yes, this is the default. π
π NOTES π
there are alternative syntaxes for referencing ordered-set aggregates, and they're described over under ALTER AGGREGATE (ALTER_AGGREGATE(7)). so if you need those, go peek there. π¦
π EXAMPLES π
wanna remove the aggregate function myavg for type integer? say less:
DROP AGGREGATE myavg(integer);
wanna remove the hypothetical-set aggregate function myrank, which takes an arbitrary list of ordering columns and a matching list of direct arguments? okay queen, here:
DROP AGGREGATE myrank(VARIADIC "any" ORDER BY VARIADIC "any");
and to remove multiple aggregate functions in one single command (efficiency!! we love her):
DROP AGGREGATE myavg(integer), myavg(bigint);
π COMPATIBILITY π
sooo there is no DROP AGGREGATE statement in the SQL standard. it's simply not a thing there. π
β SEE ALSO β
ALTER AGGREGATE(ALTER_AGGREGATE(7))CREATE AGGREGATE(CREATE_AGGREGATE(7))
and that's the whole page bestie, go forth and drop aggregates responsibly π
π§ sign-off szn: this gorgeous little doc is from PostgreSQL 17.11, dated 2026, and it's the DROP AGGREGATE(7) page. mwah. π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms