DROP_AGGREGATE(7pg18)

๐Ÿ“ฆ version 18.6, in opensuse-leap 16.0

๐Ÿ’… DROP AGGREGATE ๐Ÿ’…

okay bestie, quick vibe check: this is the page for DROP AGGREGATE from the PostgreSQL 18.6 Documentation, and it's literally the glow-up-removal era for your aggregate functions. no cap.


๐ŸŒธ NAME ๐ŸŒธ

DROP_AGGREGATE โ€” say bye-bye to an aggregate function โœจ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

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

and the aggregate_signature? she has options, and they are:

* |
[ argmode ] [ argname ] argtype [ , ... ] |
[ [ argmode ] [ argname ] argtype [ , ... ] ] ORDER BY [ argmode ] [ argname ] argtype [ , ... ]

๐Ÿ’– DESCRIPTION ๐Ÿ’–

DROP AGGREGATE removes an existing aggregate function. that's it, that's the whole plot ๐Ÿซถ

but listen โ€” to run this command, the current user must be the owner of the aggregate function. not "a friend of the owner", not "someone with good energy", the owner. ownership check is giving strict gatekeeper and honestly? respect. ๐Ÿ‘‘


โœจ PARAMETERS โœจ

  • IF EXISTS โ€” do not throw an error if the aggregate doesn't exist. instead you just get a notice. it's the polite version of "ok bestie, if she's not here, no biggie" ๐Ÿ™ˆ
  • name โ€” the name of an existing aggregate function, and yes it can be optionally schema-qualified. fancy.
  • argmode โ€” the mode of an argument: IN or VARIADIC. if you omit it, the default is IN. defaults are so main character of her.
  • argname โ€” the name of an argument. but real talk: DROP AGGREGATE does not actually pay any attention to argument names, since only the argument data types are needed to determine the aggregate function's identity. so she's hearing you, she's just not listening to the names ๐Ÿ˜ญ
  • argtype โ€” an input data type on which the aggregate function operates. 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. slay, syntax, slay. ๐Ÿ’…
  • CASCADE โ€” automatically drop objects that depend on the aggregate function (such as views using it), and in turn all objects that depend on those objects (see Section 5.15). it's giving domino effect and honestly it's a little scary ๐Ÿ“
  • RESTRICT โ€” refuse to drop the aggregate function if any objects depend on it. this is the default. so if you don't say anything, she's saying no. boundaries, iconic. ๐Ÿ’€

๐Ÿฆ‹ NOTES ๐Ÿฆ‹

alternative syntaxes for referencing ordered-set aggregates are described under ALTER AGGREGATE (ALTER_AGGREGATE(7)). go peek if you need the extended cut โœจ


๐ŸŒˆ 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:

DROP AGGREGATE myavg(integer), myavg(bigint);

one command, two aggregates gone, efficiency queen ๐Ÿ‘‘


๐Ÿ’œ COMPATIBILITY ๐Ÿ’œ

there is no DROP AGGREGATE statement in the SQL standard. so this is a PostgreSQL exclusive, and honestly? she ate. ๐Ÿ”ฅ


๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘


and that's the whole page, bestie!! ๐Ÿงš this was the PostgreSQL 18.6 docs, dated 2026, and you just read DROP AGGREGATE(7) front to back. no cap, you're basically a DBA now. go drop something (responsibly, with RESTRICT energy). ๐Ÿ’–โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from