The DROP FUNCTION statement is used to drop a stored function.
Syntax
DROP FUNCTION [IF EXISTS] sp_name
Parameters
Parameter |
Note |
|---|---|
| IF EXISTS | Optional. If the function does not exist, no error is reported; only an alert is generated. |
| sp_name | The name of the stored function to be dropped. You can use database_name.sp_name Specify the database. |
To delete a stored routine, the user must have the ALTER ROUTINE privilege on it.
If the stored function does not exist, using the IF EXISTS clause prevents errors and generates an alert that can be viewed using SHOW WARNINGS.
Examples
Deletes 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;