DROP_AGGREGATE(7pg14)
π DROP AGGREGATE β bestie's guide to yeeting an aggregate function
okay so this is the DROP AGGREGATE page from the PostgreSQL 14.24 Documentation, and honestly? it's giving "small but mighty." we're removing aggregate functions today and we're gonna slay it π
β¨ NAME β¨
DROP_AGGREGATE β remove an aggregate function ποΈβ¨
πΈ SYNOPSIS πΈ
DROP AGGREGATE [ IF EXISTS ] name ( aggregate_signature ) [, ...] [ CASCADE | RESTRICT ]
and <italic>aggregate_signature</italic> is literally this, bestie:
* |
[ argmode ] [ argname ] argtype [ , ... ] |
[ [ argmode ] [ argname ] argtype [ , ... ] ] ORDER BY [ argmode ] [ argname ] argtype [ , ... ]
no cap, that's the whole vibe right there π
π¦ DESCRIPTION π¦
DROP AGGREGATE removes an existing aggregate function. that's it, that's the post π
one thing though β to actually run this command, the current user must be the owner of the aggregate function. so like, vibe check your permissions first, fr fr.
π PARAMETERS π
IF EXISTSβ do not throw an error if the aggregate doesn't exist. a notice gets issued instead, so it's like a gentle "hmm, nothing here bestie" instead of a full meltdown πnameβ the name of an existing aggregate function, optionally schema-qualified. iykyk π«Άargmodeβ the mode of an argument:INorVARIADIC. if you omit it, the default isIN. easy β¨argnameβ the name of an argument. but heads up:DROP AGGREGATEdoesn't actually pay any attention to argument names, because only the argument data types are needed to determine the aggregate function's identity. so you can write it, it just won't be perceived πargtypeβ an input data type the aggregate function operates on. and here's the cute part:- to reference a zero-argument aggregate function, write
*in place of the list of argument specifications π - to reference an ordered-set aggregate function, write
ORDER BYbetween the direct and aggregated argument specifications π
- to reference a zero-argument aggregate function, write
CASCADEβ automatically drop objects that depend on the aggregate function (like views using it), and in turn all objects that depend on those objects (see Section 5.14). it's giving domino effect π₯RESTRICTβ refuse to drop the aggregate function if any objects depend on it. this is the default, so it's the cautious main character energy π
π§ NOTES π§
alternative syntaxes for referencing ordered-set aggregates are described under ALTER AGGREGATE (ALTER_AGGREGATE(7)). go peek if you're curious π
β EXAMPLES β
to remove the aggregate function myavg for type integer:
DROP AGGREGATE myavg(integer);
to remove the hypothetical-set aggregate function myrank, which takes an arbitrary list of ordering columns and a matching list of direct arguments:
DROP AGGREGATE myrank(VARIADIC "any" ORDER BY VARIADIC "any");
to remove multiple aggregate functions in one command β yes, multi-yeet, we love efficiency:
DROP AGGREGATE myavg(integer), myavg(bigint);
π COMPATIBILITY π
there is no DROP AGGREGATE statement in the SQL standard. not a thing. doesn't exist there. we're built different π
π SEE ALSO π
ALTER AGGREGATE(ALTER_AGGREGATE(7))CREATE AGGREGATE(CREATE_AGGREGATE(7))
and that's the whole page, bestie π this iconic little doc is PostgreSQL 14.24, dated 2026, and it will forever be known as DROP AGGREGATE(7) β periodt πβ¨π¦
π¦ where this page comes from
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-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