Drop all stored procedures in MySQL or using temporary stored procedures

后端 未结 7 2062
逝去的感伤
逝去的感伤 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-13 21:00

    @user1070300's answer seems to work, but it looks like it can drop a lot of things.

    A quick DESC mysql.proc; led me to add a WHERE to my request, so as to spare already existing MySQL procedures, which I had, of course, no reason to drop.

    I executed DELETE FROM mysql.proc WHERE db NOT LIKE 'mysql';
    If you have several bases and want to target only one, use DELETE FROM mysql.proc WHERE db LIKE '' instead;

    Btw, if like me, you are completely clearing your database and need to also drop your tables, you can use this linux shell script : mysql -Nse 'show tables' DATABASE_NAME | while read table; do mysql -e "drop table $table" DATABASE_NAME; done (see Truncate all tables in a MySQL database in one command? for more details)

    Truncate all tables in a MySQL database in one command?

提交回复
热议问题