In MySQL 8 the database table `mysql`.`proc` does not exist. Previously I used this table to delete/remove/clear all stored procedures and recreate them from the source versioned code. This works very well to make sure development stored procedures where saved to source versioning before going to production.
In MySQL versions before 8, this SQL query worked.
DELETE FROM `mysql`.`proc` WHERE `type` = 'PROCEDURE' AND `db` = 'test';
Is there an alternate way to achieve the results of the query in one statement?
The answer is you can't. But you can generate all the drop statements and execute them.
I now create all of the drop statements for stored procedures, stored functions, events, and triggers all at once using the following SQL. I use the function "DATABASE()" for ease of reuse. You can replace "DATABASE()" with the database name string "dbName" and it will work in phpMyAdmin.
SELECT CONCAT("DROP ",`item`.`ROUTINE_TYPE`," IF EXISTS `",DATABASE(),"`.`",`item`.`ROUTINE_NAME`,"`;") as `stmt`
FROM `information_schema`.`ROUTINES` AS `item`
WHERE `item`.`ROUTINE_SCHEMA` = DATABASE()
UNION
SELECT CONCAT("DROP EVENT IF EXISTS `",DATABASE(),"`.`",`item`.`EVENT_NAME`,"`;") AS `stmt`
FROM `information_schema`.`EVENTS` AS `item`
WHERE `item`.`EVENT_SCHEMA` = DATABASE()
UNION
SELECT CONCAT("DROP TRIGGER IF EXISTS `",DATABASE(),"`.`",`item`.`TRIGGER_NAME`,"`;") AS `stmt`
FROM `information_schema`.`TRIGGERS` AS `item`
WHERE `item`.`TRIGGER_SCHEMA` = DATABASE();