DROP_AGGREGATE(7pg17)

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

πŸ’… 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 either IN or VARIADIC. if you just… don't say anything, the default is IN. slay. ✨
  • argname β€” the name of an argument. but wait β€” DROP AGGREGATE does 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, write ORDER BY between 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 ⭐


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