Deletes a stored procedure.

Syntax

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

Description

You can use the DROP PROCEDURE command to delete an existing stored procedure. To run this command on a stored procedure, you must be a superuser or the owner of the procedure. If the stored procedure is overloaded, you must specify all input (IN and IN OUT) argument data types to the procedure. This requirement is not compatible with Oracle databases. In Oracle, you can only specify procedure names. PolarDB for PostgreSQL(Compatible with Oracle) allow overloading of stored procedure names, so the procedure signature that is given by the input argument data types is required in the DROP PROCEDURE command that is run on an overloaded stored procedure in PolarDB for PostgreSQL(Compatible with Oracle).

Usage of IFEXISTS, CASCADE, or RESTRICT is not compatible with Oracle databases, and can be used only by PolarDB for PostgreSQL(Compatible with Oracle).

Parameters

ParameterDescription
IF EXISTSSpecifies that the system does not report an error if the stored procedure does not exist. The server issues a notice in this case.
nameThe name of an existing stored procedure. The name can be schema-qualified.
argmodeThe modes of an argument. The argument modes include IN, IN OUT, and OUT. The default mode is IN. Note that DROP PROCEDURE is irrelevant to OUT argument, because only the input arguments are required to determine the identity of the stored procedure. Therefore, only the IN and INOUT arguments are listed. Specification of argmode is not compatible with Oracle databases and applies only to PolarDB for PostgreSQL(Compatible with Oracle).
argnameThe name of an argument. Note that DROP PROCEDURE is irrelevant to argument names, because only the argument data types are required to determine the identity of the stored procedure. Specification of argname is not compatible with Oracle databases and applies only to PolarDB for PostgreSQL(Compatible with Oracle).
argtypeThe data type of an argument of the stored procedure. Specification of argtype is not compatible with Oracle databases and applies only to PolarDB for PostgreSQL(Compatible with Oracle).
CASCADESpecifies that all objects that depend on the stored procedure and objects that depend on those objects are automatically dropped.
RESTRICTSpecifies that the stored procedure is not dropped if objects depend on it. This is the default behavior.

Examples

Delete the select_emp procedure:

DROP PROCEDURE select_emp;