SQL: deleting tables with prefix

后端 未结 10 1402
后悔当初
后悔当初 2020-11-30 17:27

How to delete my tables who all have the prefix myprefix_?

Note: need to execute it in phpMyAdmin

10条回答
  •  感动是毒
    2020-11-30 17:42

    I found that the prepared statements were a little tricky to get working for me but setting the GROUP_CONCAT_MAX_LEN was essential when you have a lot of tables. This resulted in a simple three-step process with cut-and paste from the mysql command line that worked great for me:

    SET GROUP_CONCAT_MAX_LEN=10000;
    SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' ) 
        AS statement FROM information_schema.tables 
        WHERE table_name LIKE 'myprefix_%';
    

    Then carefully cut-and-paste the resulting long DROP statement.

提交回复
热议问题