Want to implement Mysql>drop table like "prefix_%"
There are no commands that are directly available, but can be assembled by MySQL syntax,
select CONCAT ( " drop TABLE , GROUP_CONCAT (table_name), ) as statement from Information_schema.tables where table_schema ' database_name '
Then execute the assembled command, such as removing all tables from the Slowquery table that begin with the TMP_:
SELECT ' "; ' as from WHERE = ' Slowquery ' and like ' tmp_% ';
Output Result:
Drop Table
Execute it.
Examples of my own reality:
/*Auto-Generate delete dynamic table SQL statement usage: Copy to Query Analyzer to execute, copy the result and execute it OK. */SELECT REPLACE(Group_concat (A.dropsql),',',"') asDropsql from(SELECTCONCAT ('drop table', TABLE_NAME,';') asDropsql fromInformation_schema.tablesWHEREtable_name like 'slavetablemgr%'UNIONSELECTCONCAT ('drop table', TABLE_NAME,';') asDropsql fromInformation_schema.tablesWHEREtable_name like 'deviceplugin_%'UNIONSELECTCONCAT ('drop table', TABLE_NAME,';') asDropsql fromInformation_schema.tablesWHEREtable_name like 'historyrecordhour%'UNIONSELECTCONCAT ('drop table', TABLE_NAME,';') asDropsql fromInformation_schema.tablesWHEREtable_name like 'historyrecordminute%'UNIONSELECTCONCAT ('drop table', TABLE_NAME,';') asDropsql fromInformation_schema.tablesWHEREtable_name like 'historyrecordsecond%') A;
MySQL: Bulk Delete Tables by prefix