DROP_PROCEDURE(7)
๐ 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, orVARIADIC. if you omit it, the default isIN(but see below, bestie, there's lore). ๐argnameโ the name of an argument. and okay, plot twist:DROP PROCEDUREdoes 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 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. 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 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))
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
- alpine 3.23: postgresql18-doc 18.6-r0 ยท PostgreSQL
- alpine 3.24: postgresql18-doc 18.6-r0 ยท PostgreSQL
- arch rolling: postgresql 18.6-4 ยท PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 ยท PostgreSQL
- fedora 43: postgresql 18.6-1.fc43 ยท PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 ยท PostgreSQL
- fedora 44: postgresql 18.6-1.fc44 ยท PostgreSQL
- nixos 26.05: postgresql 18.6
- ubuntu resolute: postgresql-client-18 18.6-0ubuntu0.26.04.1 ยท PostgreSQL
- ubuntu stonking: postgresql-client-18 18.6-3build2 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms