DROP_ROUTINE(7pg16)

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

πŸ’… DROP_ROUTINE β€” bestie's guide to yeeting a routine

okay so real talk, this is DROP_ROUTINE from the PostgreSQL 16.15 docs, and it's genuinely one of the most underrated little commands out there. it removes a routine. that's the whole vibe. let's get into it 🫢


✨ SYNOPSIS ✨

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

like, look at her. multi-routine capable. optional args. cascade or restrict. she's got range πŸ”₯


🌸 DESCRIPTION 🌸

DROP ROUTINE removes the definition of one or more existing routines. and when we say "routine", we mean it in the big-tent sense β€” the term "routine" includes aggregate functions, normal functions, and procedures. one command to drop them all, no cap πŸ‘‘

for the actual deets on parameters, more examples, and further details, please go check under DROP AGGREGATE (DROP_AGGREGATE(7)), DROP FUNCTION (DROP_FUNCTION(7)), and DROP PROCEDURE (DROP_PROCEDURE(7)). she's the generalist, they're the specialists. iykyk πŸ’…


πŸ¦‹ NOTES πŸ¦‹

okay this part is important, don't skip it, i'm serious:

  • 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, btw. 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 even when a more specific command (DROP FUNCTION, etc.) would totally work. the fix? specify the argument type list more carefully. that also resolves such problems. slay ✨
  • these lookup rules are also used by other commands that act on existing routines, such as ALTER ROUTINE and COMMENT ON ROUTINE. so like, knowing this is a whole personality trait at this point 🧚

πŸ’– EXAMPLES πŸ’–

okay so say you wanna drop the routine foo for type integer:

DROP ROUTINE foo(integer);

and the beautiful part? this command will work independent of whether foo is an aggregate, function, or procedure. it does not care. it does not ask questions. it just drops. iconic behavior honestly πŸŽ€


🌈 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 "actually, more." main character energy ⭐)
  • 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 πŸ‘‘

bestie heads up: note that there is no CREATE ROUTINE command. don't go looking for her, she's not coming to the function πŸ˜­πŸ’€

and that's the whole page! brought to you by the PostgreSQL 16.15 documentation, dated 2026 β€” go forth and drop responsibly, mwah πŸ’œπŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from