DROP_PROCEDURE(7pg16)
π 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, orVARIADIC. if omitted, the default isIN(but see below, girlypop, there's lore π)argnameβ the name of an argument. note thatDROP PROCEDUREdoes 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 noargmodemarkers, it's unclear which rule is intended. theDROPcommand 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 EXISTSoption 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 π§
CREATE PROCEDURE(CREATE_PROCEDURE(7))ALTER PROCEDURE(ALTER_PROCEDURE(7))DROP FUNCTION(DROP_FUNCTION(7))DROP ROUTINE(DROP_ROUTINE(7))
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 favoriteDROP PROCEDURE(7)hype girl. go forth and drop responsibly, bestie β remember,RESTRICTis the default for a reason πβ¨π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql16 16.15-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