This documentation is for an older version. If you're using the most current version, select the documentation for that version with the version switch in the upper right corner of the online documentation, or by downloading a newer PDF or EPUB file.



This statement is used to drop a stored procedure or function. That is, the specified routine is removed from the server. As of MySQL 5.0.3, you must have the ALTER ROUTINE privilege for the routine. (If the automatic_sp_privileges system variable is enabled, that privilege and EXECUTE are granted automatically to the routine creator when the routine is created and dropped from the creator when the routine is dropped. See Section 18.2.2, “Stored Routines and MySQL Privileges”.)

The IF EXISTS clause is a MySQL extension. It prevents an error from occurring if the procedure or function does not exist. A warning is produced that can be viewed with SHOW WARNINGS.


DROP PROCEDURE IF EXISTS and DROP FUNCTION IF EXISTS are not written to the binary log (and thus not replicated) if the stored procedure or function named in the DROP statement does not exist on the master. This is a known issue, which is resolved in MySQL 5.1 and later. (Bug #13684)

DROP FUNCTION is also used to drop user-defined functions (see Section, “DROP FUNCTION Syntax”).