DROP_ROUTINE(7pg14)

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

πŸ’… DROP_ROUTINE πŸ’…

okay so this is DROP_ROUTINE(7) from the PostgreSQL 14.24 docs, and honestly? it's the "one command to rule them all" of dropping routines. bestie, let me put you on. 🫢


✨ NAME ✨

DROP_ROUTINE β€” remove a routine. that's it. that's the vibe. bye-bye routine πŸ‘‹


πŸŽ€ SYNOPSIS πŸŽ€

DROP ROUTINE [ IF EXISTS ] name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] [, ...]
    [ CASCADE | RESTRICT ]

look at that beautiful nesting. she's got depth. πŸ’…


🌸 DESCRIPTION 🌸

DROP ROUTINE removes the definition of one or more existing routines. and before you ask β€” the term "routine" is a whole umbrella situation, it includes aggregate functions, normal functions, and procedures. all of them. one big happy family. πŸ‘‘

for the description of the parameters, more examples, and further details, go peek under DROP AGGREGATE (DROP_AGGREGATE(7)), DROP FUNCTION (DROP_FUNCTION(7)), and DROP PROCEDURE (DROP_PROCEDURE(7)). they're the sibling man pages and they ate. ✨


πŸ¦‹ NOTES πŸ¦‹

the lookup rules used by DROP ROUTINE are fundamentally the same as for DROP PROCEDURE. in particular, 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. (DROP AGGREGATE and DROP FUNCTION do not do that, fyi. they're different like that. πŸ™ˆ)

in some cases where the same name is shared by routines of different kinds, it is possible for DROP ROUTINE to fail with an ambiguity error when a more specific command (DROP FUNCTION, etc.) would work. specifying the argument type list more carefully will also resolve such problems. so like... be specific. communicate. it's giving healthy relationship. 😭

these lookup rules are also used by other commands that act on existing routines, such as ALTER ROUTINE and COMMENT ON ROUTINE. iykyk.


πŸ’– EXAMPLES πŸ’–

to drop the routine foo for type integer:

DROP ROUTINE foo(integer);

this command will work independent of whether foo is an aggregate, function, or procedure. no cap. it just knows. πŸ”₯


🌈 COMPATIBILITY 🌈

this command conforms to the SQL standard, with these PostgreSQL extensions:

  • the standard only allows one routine to be dropped per command. we said no thanks bestie, we're doing more. πŸ’…
  • the IF EXISTS option 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 ⭐

note that there is no CREATE ROUTINE command. yeah. that's not a thing. don't come for me, i don't make the rules. πŸ’€

and that's the whole page, bestie! πŸŽ€ this little number is from PostgreSQL 14.24, dated 2026 β€” iconic, timeless, slaying across the decades. mwah. πŸ’œ

πŸ“¦ where this page comes from