想要实现mysql>drop table like "table_name%"
没有直接可用的命令,不过可以通过mysql语法来组装,
- SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' )
- AS statement FROM information_schema.tables
- WHERE table_schema = 'database_name' AND table_name LIKE 'table_name%';
然后执行该组装后的命令,比如从database_name数据库中删除掉所有table_name开头的表:
- SELECT CONCAT( 'DROP TABLE ', GROUP_CONCAT(table_name) , ';' ) AS statement FROM information_schema.tables WHERE table_schema = 'database_name' AND table_name LIKE 'table_name%';
输出结果:
- drop table table_name213, table_name34dfk
执行之即可。