How can we delete a MySQL stored function from the database?

MySQLMySQLi Database

If we have ALTER ROUTINE privileges then with the help of DROP FUNCTION statement, we can delete a MySQL stored function. Its syntax can be as follows −

Syntax

DROP FUNCTION [IF EXISTS] function_name

Here function_name is the name of the function which we want to delete from our database.

Example

mysql> DROP FUNCTION if exists Hello1;
Query OK, 0 rows affected (0.70 sec)

Now after deleting the function, check for the CREATE FUNCTION statement and we will get the error as follows −

mysql> SHOW CREATE FUNCTION Hello1;
ERROR 1305 (42000): Function Hello1 does not exist.
raja
Published on 21-Feb-2018 12:13:47
Advertisements