Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete all procedures of a database in mysql5

I want to delete all procedures from my MySQL database sbnmaster. How should I write a query for this?

like image 966
learner Avatar asked Dec 05 '22 20:12

learner


2 Answers

Try this

USE sbnmaster;

SELECT CONCAT("DROP PROCEDURE IF EXISTS ",SPECIFIC_NAME) AS StorePrecedure 
FROM information_schema.ROUTINES R 
WHERE R.ROUTINE_TYPE = "PROCEDURE" 
AND R.ROUTINE_SCHEMA = DATABASE(); 
like image 133
Rahul Avatar answered Dec 10 '22 11:12

Rahul


Not sure that it is correct, but seems it works -

DELETE FROM mysql.proc WHERE db = 'sbnmaster' AND type = 'PROCEDURE';
like image 34
Devart Avatar answered Dec 10 '22 11:12

Devart