Remove a function.
Syntax
DROP FUNCTION [ IF EXISTS ] name
[ ([ [ argmode ] [ argname ] argtype ] [, ...]) ]
[ CASCADE | RESTRICT ]
Description
You can run the DROP FUNCTION
command to remove an existing function. To run this command, you must be a superuser or the owner of the function. All data types of the input argument in the mode of IN
or IN OUT
to the function must be specified if this is an overloaded function. This requirement is not compatible with Oracle databases. In Oracle, only the function name is specified. PolarDB for PostgreSQL(Compatible with Oracle) allows overloading of function names, so the function signature provided by the input argument data types is required in the DROP FUNCTION command of an overloaded function.
The usage of IFEXISTS
, CASCADE
, or RESTRICT
is not compatible with Oracle databases and is used only by PolarDB for PostgreSQL(Compatible with Oracle).
Parameters
Parameter | Description |
---|
Parameter | Description |
---|---|
IF EXISTS | Dose not throw an error if the function does not exist. In this case, a notification is issued. |
name | The name of an existing function, which may be optional and schema-qualified. |
argmode | The mode of an argument. Valid values: IN , IN OUT or OUT . If this parameter is omitted, the default is IN . The DROP FUNCTION is not actually affected by the OUT arguments, since only the input arguments are required to determine the identity of the function. So it is sufficient to list only the IN and INOUT arguments. The specification of argmode is not compatible with Oracle databases and applies only to PolarDB for PostgreSQL(Compatible with Oracle). |
argname | The name of an argument. The DROP FUNCTION is not actually affected by argument names, since only the argument data types are required to determine the identity of the function. The specification of argname is not compatible with Oracle databases and applies only to PolarDB for PostgreSQL(Compatible with Oracle). |
argtype | The data type of an argument of the function. The specification of argtype is not compatible with Oracle databases and applies only to PolarDB for PostgreSQL(Compatible with Oracle). |
CASCADE | Automatically drop objects that depend on the function (such as operators or triggers), and in turn all objects that depend on those objects. |
RESTRICT | Refuses to drop the function if any objects depend on it. This is the default value. |
Example
The following command removes the emp_comp function.
DROP FUNCTION emp_comp(NUMBER, NUMBER);