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
I can almost get working a piece of code to drop all stored procs, but I think MySQL isn't letting me use a LOOP or a CURSOR outside of a stored procedure.
I can write a SQL file that counts the number of stored procedures for a given schema, and I have the code to iterate through the table and drop procedures, but I can't get it to run:
SELECT COUNT(ROUTINE_NAME)
INTO @remaining
FROM information_schema.ROUTINES
WHERE ROUTINE_SCHEMA = SCHEMA()
AND ROUTINE_TYPE = 'FUNCTION';
kill_loop: LOOP
IF @remaining < 1 THEN
LEAVE kill_loop;
END IF;
SELECT ROUTINE_NAME
INTO @cur_func_name
FROM information_schema.ROUTINES
WHERE ROUTINE_SCHEMA = SCHEMA()
AND ROUTINE_TYPE = 'FUNCTION'
LIMIT 1;
DROP FUNCTION @cur_func_name;
@remaining = @remaining - 1;
END LOOP;