DROP_AGGREGATE(7pg14)

πŸ“¦ version 14.24, in opensuse-leap 16.0

πŸ’… 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: IN or VARIADIC. if you omit it, the default is IN. easy ✨
  • argname β€” the name of an argument. but heads up: DROP AGGREGATE doesn'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 BY between the direct and aggregated argument specifications 🌈
  • 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 🌈


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