2012年10月29日 星期一

Drop Multiple MySQL tables

You can show tables with wildcard character on MySQL server.
ie: SHOW TABLES LIKE 'PREFIX_%';

But can't drop multiple tables with '%'.

[HowTo]
For shell script:

for T in `echo "SHOW TABLES" |mysql db|grep "^PREFIX_"`; do echo "DROP TABLE $T;"|mysql db;done

enjoy it.
:D

沒有留言:

張貼留言