DROP_AGGREGATE(7)
๐ 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:INorVARIADIC. if you omit it, the default isIN. defaults are so main character of her.argnameโ the name of an argument. but real talk:DROP AGGREGATEdoes 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, writeORDER BYbetween 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 ๐
ALTER AGGREGATE(ALTER_AGGREGATE(7))CREATE AGGREGATE(CREATE_AGGREGATE(7))
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
- alpine 3.23: postgresql18-doc 18.6-r0 ยท PostgreSQL
- alpine 3.24: postgresql18-doc 18.6-r0 ยท PostgreSQL
- arch rolling: postgresql 18.6-4 ยท PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 ยท PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 ยท PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 ยท PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 ยท PostgreSQL
- nixos 26.05: postgresql 18.6
- ubuntu resolute: postgresql-client-18 18.6-0ubuntu0.26.04.1 ยท PostgreSQL
- ubuntu stonking: postgresql-client-18 18.6-3build2 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms