DROP FUNCTION

Synopsis

Use the DROP FUNCTION statement to remove a function from a database.

Syntax

drop_function ::= DROP FUNCTION [ IF EXISTS ]  
                  { subprogram_name ( [ subprogram_signature ] ) } 
                  [ , ... ] [ CASCADE | RESTRICT ]

subprogram_signature ::= arg_decl [ , ... ]

arg_decl ::= [ formal_arg ] [ arg_mode ] arg_type

drop_function

DROPFUNCTIONIFEXISTS,subprogram_name(subprogram_signature)CASCADERESTRICT

subprogram_signature

,arg_decl

arg_decl

formal_argarg_modearg_type

You must identify the to-be-dropped function by:

  • Its name and the schema where it lives. This can be done by using its fully qualified name or by using just its bare name and letting name resolution find it in the first schema on the search_path where it occurs. Notice that you don't need to (and cannot) mention the name of its owner.

  • Its signature. The subprogram_call_signature is sufficient; and this is typically used. You can use the full subprogram_signature. But you should realize that the formal_arg and arg_mode for each arg_decl carry no identifying information. (This is why it is not typically used when a function or procedure is to be altered or dropped.) This is explained in the section Subprogram overloading.

Semantics

  • An error will be thrown if the function does not exist unless IF EXISTS is used. Then a notice is issued instead.

  • RESTRICT is the default and it will not drop the function if any objects depend on it.

  • CASCADE will drop any objects that transitively depend on the function.

Examples

DROP FUNCTION IF EXISTS inc(i integer), mul(integer, integer) CASCADE;

See also