DROP_PROCEDURE(7pg16)

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

πŸ’… DROP PROCEDURE πŸ’…

okay bestie, so this is the DROP PROCEDURE(7) page straight out of the PostgreSQL 16.15 Documentation, and I'm gonna walk you through it like we're texting at 2am 🫢


✨ NAME ✨

DROP_PROCEDURE β€” remove a procedure. literally just yeeting a procedure out of existence, no cap πŸ”₯


πŸŽ€ SYNOPSIS πŸŽ€

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

look at her. iconic syntax. she's got optionality for days πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

DROP PROCEDURE removes the definition of one or more existing procedures β€” like, poof, gone, she's not on the roster anymore ✨

to run this command you gotta be the owner of the procedure(s). that's the vibe check and you must pass it πŸ‘‘

also? the argument types to the procedure(s) usually must be specified, because several different procedures can exist with the same name and different argument lists. so like, do_stuff could be three different girls and you need to specify which one 😭


🌸 PARAMETERS 🌸

  • IF EXISTS β€” do not throw an error if the procedure does not exist. a notice is issued in this case. so basically: if she's not there, don't make it weird, just log a lil notice πŸ™ˆ
  • name β€” the name (optionally schema-qualified) of an existing procedure. yes you can schema-qualify her, she's that kind of girl πŸ’–
  • argmode β€” the mode of an argument: IN, OUT, INOUT, or VARIADIC. if omitted, the default is IN (but see below, girlypop, there's lore πŸ‘€)
  • argname β€” the name of an argument. note that DROP PROCEDURE does not actually pay any attention to argument names, since only the argument data types are used to determine the procedure's identity. so don't stress about the name, she's not reading it πŸ’€
  • argtype β€” the data type(s) of the procedure's arguments (optionally schema-qualified), if any. see below for details ✨
  • CASCADE β€” automatically drop objects that depend on the procedure, and in turn all objects that depend on those objects (see Section 5.14). it's giving domino effect, it's giving "you came for one and now everybody's gone" πŸ”₯
  • RESTRICT β€” refuse to drop the procedure if any objects depend on it. this is the default. she's cautious. she's responsible. she's the mom friend πŸŽ€

πŸ’œ NOTES πŸ’œ

if there is only one procedure of the given name, the argument list can be omitted. omit the parentheses too in this case β€” like, just don't even bother, queen πŸ’…

in PostgreSQL, it's sufficient to list the input (including INOUT) arguments, because no two routines of the same name are allowed to share the same input-argument list. slay, that's the whole identity system fr fr.

moreover, the DROP command will not actually check that you wrote the types of OUT arguments correctly; so any arguments that are explicitly marked OUT are just noise. literal noise. background static. πŸ’€ but writing them is recommendable for consistency with the corresponding CREATE command β€” so it's optional but it's aesthetic ✨

for compatibility with the SQL standard, it is also allowed to write all the argument data types (including those of OUT arguments) without any argmode markers. when this is done, the types of the procedure's OUT argument(s) will be verified against the command.

⚠️ okay so here's the drama: this provision creates an ambiguity, in that when the argument list contains no argmode markers, it's unclear which rule is intended. the DROP command will attempt the lookup both ways, and will throw an error if two different procedures are found. 😭

to avoid the risk of such ambiguity, it's recommendable to write IN markers explicitly rather than letting them be defaulted, thus forcing the traditional PostgreSQL interpretation to be used. protect your peace, be explicit πŸ’–

the lookup rules just explained are also used by other commands that act on existing procedures, such as ALTER PROCEDURE and COMMENT ON PROCEDURE. so like, this isn't just a DROP thing, it's a whole family thing 🫢


🌈 EXAMPLES 🌈

if there is only one procedure do_db_maintenance, this command is sufficient to drop it:

DROP PROCEDURE do_db_maintenance;

given this procedure definition:

CREATE PROCEDURE do_db_maintenance(IN target_schema text, OUT results text) ...

any one of these commands would work to drop it:

DROP PROCEDURE do_db_maintenance(IN target_schema text, OUT results text);
DROP PROCEDURE do_db_maintenance(IN text, OUT text);
DROP PROCEDURE do_db_maintenance(IN text);
DROP PROCEDURE do_db_maintenance(text);
DROP PROCEDURE do_db_maintenance(text, text);  -- potentially ambiguous

however, the last example would be ambiguous if there is also, say,

CREATE PROCEDURE do_db_maintenance(IN target_schema text, IN options text) ...

see?? that last one is the risky one. she's living dangerously. -- potentially ambiguous is literally the warning label on her πŸš¨πŸ’€


⭐ COMPATIBILITY ⭐

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

  • the standard only allows one procedure to be dropped per command. (we said naur πŸ’…)
  • 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.

🧚 SEE ALSO 🧚

the whole friend group honestly 🫢 go read them too, iykyk


🌟 and that's the page!! brought to you by PostgreSQL 16.15, dated 2026, and delivered with love from your favorite DROP PROCEDURE(7) hype girl. go forth and drop responsibly, bestie β€” remember, RESTRICT is the default for a reason πŸ’–βœ¨πŸŽ€
πŸ“¦ where this page comes from