Drop all stored procedures in MySQL or using temporary stored procedures

后端 未结 7 2052
逝去的感伤
逝去的感伤 2020-12-13 20:39

Is there a statement that can drop all stored procedures in MySQL? Alternatively (if the first one is not possible), is there such thing as temporary stored procedures in My

相关标签:
7条回答
  • 2020-12-13 21:11

    Since DROP PROCEDURE and DROP FUNCTION does not allow sub selects, I thought it might be possible to perform the operation through another stored procedure, but alas, MySQL does not allow stored procedures to drop other stored procedures.

    I tried to trick MySQL to to this anyway by creating prepared statements and thus separating the drop call somewhat from the stored procedure, but I've had no luck.

    So therefore my only contribution is this select statement which creates a list of the statements needed to drop all stored procedures and functions.

    SELECT
        CONCAT('DROP ',ROUTINE_TYPE,' `',ROUTINE_SCHEMA,'`.`',ROUTINE_NAME,'`;') as stmt
    FROM information_schema.ROUTINES;
    
    0 讨论(0)
提交回复
热议问题