DROP {PROCEDURE | FUNCTION} [IF EXISTS] sp_name
语句用于丢弃存储例程(存储过程或函数)。也就是说,指定的例程从服务器中移除。(DROP FUNCTION 也用于丢弃可加载函数;参见 第 15.7.4.2 节,“DROP FUNCTION Statement for Loadable Functions”。)These statements are used to drop a stored routine (a stored
procedure or function). That is, the specified routine is removed
from the server. (DROP FUNCTION is also used to
drop loadable functions; see
Section 15.7.4.2, “DROP FUNCTION Statement for Loadable Functions”.)
要丢弃存储例程,必须拥有 ALTER ROUTINE 权限。(如果启用 automatic_sp_privileges系统变量,该权限和 EXECUTE 会自动授予例程创建者,丢弃例程时从创建者中丢弃。参见 第 27.2.2 节,“存储例程与 MySQL 权限”。)To drop a stored routine, you must have the
ALTER ROUTINE privilege for it. (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 27.2.2, “Stored Routines and MySQL Privileges”.)
此外,如果例程的定义器拥有 SYSTEM_USER 权限,则丢弃该权限的用户也必须拥有该权限。In addition, if the definer of the routine has the
SYSTEM_USER privilege, the user
dropping it must also have this privilege.
IF EXISTS 子句是 MySQL 的一个扩展。它防止在过程或函数不存在时发生错误。生成的警告可显示为 SHOW WARNINGS“。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 FUNCTION 也用于丢弃可加载函数(参见 第 15.7.4.2 节,”DROP FUNCTION Statement for Loadable Functions“)。DROP FUNCTION is also used to drop
loadable functions (see Section 15.7.4.2, “DROP FUNCTION Statement for Loadable Functions”).