DROP ROUTINE
DROP ROUTINE — remove a routine
Synopsis
DROP ROUTINE [ IF EXISTS ]name
[ ( [ [argmode
] [argname
]argtype
[, ...] ] ) ] [, ...] [ CASCADE | RESTRICT ]
Description
DROP ROUTINE
removes the definition of one or more existing routines. The term“routine” includes aggregate functions, normal functions, and procedures. See underDROP AGGREGATE,DROP FUNCTION, andDROP PROCEDURE for the description of the parameters, more examples, and further details.
Notes#
The lookup rules used byDROP ROUTINE
are fundamentally the same as forDROP PROCEDURE
; in particular,DROP ROUTINE
shares that command's behavior of considering an argument list that has noargmode
markers to be possibly using the SQL standard's definition thatOUT
arguments are included in the list. (DROP AGGREGATE
andDROP FUNCTION
do not do that.)
In some cases where the same name is shared by routines of different kinds, it is possible forDROP 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 asALTER ROUTINE
andCOMMENT ON ROUTINE
.
Examples#
To drop the routinefoo
for typeinteger
:
DROP ROUTINE foo(integer);
This command will work independent of whetherfoo
is an aggregate, function, or procedure.
Compatibility#
This command conforms to the SQL standard, with thesePostgres Pro extensions:
The standard only allows one routine 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.
User-definable aggregate functions are an extension.
See Also
DROP AGGREGATE,DROP FUNCTION,DROP PROCEDURE,ALTER ROUTINE Note that there is noCREATE ROUTINE
command.