DROP ROUTINE(7) PostgreSQL 14.23 Documentation DROP ROUTINE(7)
DROP_ROUTINE - remove a routine
| Use Case | Command | Description |
|---|---|---|
| Drop a single routine by name | DROP ROUTINE name; | Remove an existing routine |
| Drop with IF EXISTS | DROP ROUTINE IF EXISTS name; | Remove routine if it exists, no error if missing |
| Drop a specific overloaded routine | DROP ROUTINE name(argtype); | Remove a routine with a specific argument type list |
| Drop with CASCADE | DROP ROUTINE name CASCADE; | Remove routine and dependent objects |
| Drop multiple routines | DROP ROUTINE name1, name2; | Remove multiple routines in one command |
DROP ROUTINE [ IF EXISTS ] name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] [, ...]
[ CASCADE | RESTRICT ]
DROP ROUTINE removes the definition of one or more existing routines. The term βroutineβ includes aggregate functions, normal functions, and procedures. See under DROP AGGREGATE(7), DROP FUNCTION(7), and DROP PROCEDURE(7) for the description of the parameters, more examples, and further details.
The lookup rules used by DROP ROUTINE are fundamentally the same as for DROP PROCEDURE; in particular, DROP ROUTINE shares that command's behavior of considering an argument list that has no argmode markers to be possibly using the SQL standard's definition that OUT arguments are included in the list. (DROP AGGREGATE and DROP FUNCTION do not do that.)
In some cases where the same name is shared by routines of different kinds, it is possible for DROP ROUTINE to fail with an ambiguity error when a more specific command (DROP FUNCTION, etc.) would work. Specifying the argument type list more carefully will also resolve such problems.
These lookup rules are also used by other commands that act on existing routines, such as ALTER ROUTINE and COMMENT ON ROUTINE.
To drop the routine foo for type integer:
DROP ROUTINE foo(integer);
This command will work independent of whether foo is an aggregate, function, or procedure.
This command conforms to the SQL standard, with these PostgreSQL extensions:
DROP AGGREGATE(7), DROP FUNCTION(7), DROP PROCEDURE(7), ALTER ROUTINE(7)
Note that there is no CREATE ROUTINE command.
PostgreSQL 14.23 2026 DROP ROUTINE(7)
Generated by phpman v4.9.26-5-g7740029 Author: Che Dong Under GNU General Public License
2026-08-23 23:09 @216.73.216.102
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)