MySQL bulk drop table where table like?

前端 未结 5 2023
暖寄归人
暖寄归人 2020-12-12 21:50
DROP TABLE (
SELECT table_name
FROM information_schema.`TABLES`
WHERE table_schema = \'myDatabase\' AND table_name LIKE BINARY \'del%\');

I know th

5条回答
  •  天命终不由人
    2020-12-12 22:02

    You can do this quickly and easily if you have phpMyAdmin available and the requirement is to drop tables with a specific prefix. Go to the database you want, and show the list of all the tables. Since tables are shown in alphabetic order, the tables with the prefix for deletion will all appear together. Go to the first one, and click the tick box on the left hand side. Then scroll down to the last table with the prefix, hold down shift, and click the tick box. That results in all the tables with the prefix being ticked. Go to the bottom of the list, and select the action drop for all selected tables. Go through with the deletion, checking that the SQL generated looks right!

提交回复
热议问题