The DROP FUNCTION statement is used to drop a stored function.
Syntax
DROP FUNCTION [IF EXISTS] sp_name
Parameters
Parameter |
Description |
|---|---|
| IF EXISTS | Optional. If the function does not exist, it will not generate an error, but will generate a warning. |
| sp_name | The name of the stored function to be dropped. You can use database_name.sp_name to specify the database. |
To drop a stored routine, the user must have the ALTER ROUTINE privilege.
If the stored function does not exist, using the IF EXISTS clause can prevent an error and generate a warning, which can be viewed using SHOW WARNINGS.
Examples
Drop a stored function.
obclient> DROP FUNCTION IF EXISTS my_func;
Drop a stored function in a specified database:
obclient> DROP FUNCTION IF EXISTS test_db.calculate_sum;
