MySQL bulk drop table where table like?

前端 未结 5 2019
暖寄归人
暖寄归人 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:11

    If you just need to quickly drop a bunch of tables (not in pure SQL, so not directly answering this question) a one line shell command can do it:

    echo "show tables like 'fsm%'" | mysql | tail +2 | while read t; do echo "drop table \`$t\`;"; done | mysql
    

提交回复
热议问题