DROP_PROCEDURE(7pg18)

๐Ÿ“ฆ version 18.6, in opensuse-leap 16.0

๐Ÿ’… DROP PROCEDURE ๐Ÿ’…

okay bestie, so this is the PostgreSQL 18.6 documentation page for DROP PROCEDURE, and honestly? it's giving "spring cleaning but for your database." let's get into it โœจ


โœจ NAME โœจ

DROP_PROCEDURE โ€” remove a procedure ๐Ÿ—‘๏ธ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

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

like... yes, there are a lot of brackets. breathe. we'll break it down ๐Ÿ’–


๐ŸŒธ DESCRIPTION ๐ŸŒธ

DROP PROCEDURE removes the definition of one or more existing procedures. poof, gone, no cap. ๐Ÿซถ

but here's the thing โ€” to run this command, the user must be the owner of the procedure(s). you can't just walk into someone else's schema and start deleting stuff, that's not main character energy, that's just rude.

also, you usually must specify the argument types to the procedure(s), because several different procedures can totally exist with the same name and different argument lists. so the arg types are literally how the database tells them apart. iykyk ๐Ÿ‘‘


๐Ÿฆ‹ PARAMETERS ๐Ÿฆ‹

  • IF EXISTS โ€” do not throw an error if the procedure does not exist. instead a notice is issued. it's the "no worries if not!!" of SQL ๐Ÿ’–
  • name โ€” the name (optionally schema-qualified) of an existing procedure. โœจ
  • argmode โ€” the mode of an argument: IN, OUT, INOUT, or VARIADIC. if you omit it, the default is IN (but see below, bestie, there's lore). ๐ŸŒˆ
  • argname โ€” the name of an argument. and okay, plot twist: 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 the name is basically decorative here ๐Ÿ™ˆ
  • 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.15). it's a chain reaction, and it does not stop ๐Ÿ’€
  • RESTRICT โ€” refuse to drop the procedure if any objects depend on it. this is the default. ๐Ÿ›‘

๐Ÿ’œ NOTES ๐Ÿ’œ

if there is only one procedure of the given name, the argument list can be omitted. omit the parentheses too in this case. yes, fully naked. no parens. she's free โœจ

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. 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. BUT writing them is recommendable for consistency with the corresponding CREATE command. so like, they're useless but also cute, and consistency is a vibe ๐ŸŽ€

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. ๐Ÿงš

but 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. say what you mean, bestie ๐Ÿ’…

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 this isn't a one-off, it's a whole ecosystem ๐Ÿฆ‹


๐Ÿ”ฅ 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) ...

like... that last one is the "idk which one you meant" moment. proceed with caution ๐Ÿ‘€


๐Ÿ‘‘ COMPATIBILITY ๐Ÿ‘‘

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

  • the standard only allows one procedure to be dropped per command.
  • 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 ๐ŸŒˆ


and that's the whole page, babe ๐Ÿซถ this was brought to you by PostgreSQL 18.6, dated 2026 โ€” go forth, drop responsibly, and always be the owner of the procedure you're deleting ๐Ÿ’–โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from