DROP_ROUTINE(7pg15)
π DROP_ROUTINE β ok bestie, let's yeet a routine π
So you've got a routine you don't vibe with anymore? This is the page for you, gorgeous. It's DROP ROUTINE from the PostgreSQL 15.19 docs, and yes it absolutely ate.
β¨ SYNOPSIS β¨
DROP ROUTINE [ IF EXISTS ] name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] [, ...]
[ CASCADE | RESTRICT ]
That's the whole flex. Look at it. Iconic.
π¦ DESCRIPTION π¦
DROP ROUTINE removes the definition of one or more existing routines. And lowkey the word "routine" is doing a lot of heavy lifting here β it's the umbrella term that includes aggregate functions, normal functions, and procedures. All three, one cute little command. Main character energy fr fr.
But listen, if you want the actual deets on the parameters, more examples, and further details, the manual is basically like "go read the specific ones, babe":
DROP AGGREGATE(DROP_AGGREGATE(7))DROP FUNCTION(DROP_FUNCTION(7))DROP PROCEDURE(DROP_PROCEDURE(7))
π NOTES π (read these, seriously)
Okay so the lookup rules DROP ROUTINE uses are fundamentally the same as DROP PROCEDURE's. And in particular β this is the important bit β DROP ROUTINE shares that command's behavior of considering an argument list that has no argmode markers to be possibly using the SQL standard's definition that OUT arguments are included in the list.
Not me being shady but:DROP AGGREGATEandDROP FUNCTIONdo not do that. So there's the tea. π΅
And here's a little gotcha πΈ β sometimes the same name is shared by routines of different kinds, and in those cases it's possible for DROP ROUTINE to fail with an ambiguity error even when a more specific command (DROP FUNCTION, etc.) would totally work fine. The fix? Specify the argument type list more carefully. That resolves it. Slay.
Also good to know: these same lookup rules are used by other commands that act on existing routines, like ALTER ROUTINE and COMMENT ON ROUTINE. So this isn't just a DROP ROUTINE thing, iykyk.
π EXAMPLES π
Want to drop the routine foo for type integer? Say less:
DROP ROUTINE foo(integer);
And the best part? This command will work independent of whether foo is an aggregate, function, or procedure. One command, all the vibes. Periodt. π
β¨
π COMPATIBILITY π
This command conforms to the SQL standard β but with these PostgreSQL extensions, bestie:
- The standard only allows one routine to be dropped per command. (We allow more. We're generous like that. π«Ά)
- The
IF EXISTSoption is an extension. - The ability to specify argument modes and names is an extension, and the lookup rules differ when modes are given.
- User-definable aggregate functions are an extension.
β SEE ALSO β
Go check these out, they're all linked and cute:
DROP AGGREGATE(DROP_AGGREGATE(7))DROP FUNCTION(DROP_FUNCTION(7))DROP PROCEDURE(DROP_PROCEDURE(7))ALTER ROUTINE(ALTER_ROUTINE(7))
And just so you're not out here looking forever: note that there is no CREATE ROUTINE command. π Not a thing. Don't go looking for it.
π that's the whole page, bestie π β brought to you by PostgreSQL 15.19, dated 2026. Go forth and drop responsibly. π¦π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-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