DROP_PROCEDURE(7pg15)

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

okay so bestie, this is the DROP PROCEDURE(7) page (yes, the DROP_PROCEDURE(7pg15) manual) from the PostgreSQL 15.19 Documentation ✨ it's literally about removing procedures, and we're gonna make it make sense. iykyk πŸ’…

πŸŽ€ NAME πŸŽ€

DROP_PROCEDURE β€” remove a procedure. that's the vibe, periodt.

✨ SYNOPSIS ✨

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

πŸ’– DESCRIPTION πŸ’–

DROP PROCEDURE removes the definition of one or more existing procedures. To run this command, you have to be the owner of the procedure(s), no cap. You usually have to specify the argument types for the procedure(s), since several different procedures can exist with the same name and different argument lists. it's giving "identity crisis? not on my watch" πŸ’…

🌸 PARAMETERS 🌸

  • IF EXISTS β€” don't throw an error if the procedure doesn't exist. In that case, a notice is issued instead. lowkey polite.
  • name β€” the name of an existing procedure, optionally schema-qualified.
  • argmode β€” the mode of an argument: IN, OUT, INOUT, or VARIADIC. If omitted, the default is IN (but see below, bestie).
  • 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.
  • 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).
  • 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. cute and efficient.

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. bestie, consistency is free πŸ’…

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. 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. that's the safe route, 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. iykyk.

🌈 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) ...

πŸ‘‘ 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 πŸ”₯

CREATE PROCEDURE (CREATE_PROCEDURE(7)), ALTER PROCEDURE (ALTER_PROCEDURE(7)), DROP FUNCTION (DROP_FUNCTION(7)), DROP ROUTINE (DROP_ROUTINE(7))


PostgreSQL 15.19 Β· 2026 Β· DROP PROCEDURE(7) β€” that's the source/version and date, bestie, and that's the whole cute sign-off βœ¨πŸ«ΆπŸ’…

πŸ“¦ where this page comes from