Overviewprior to debugging in the work of a cron timed task that executes every minute, each minute produces a table name with time information, and forgot to delete the scheduled task, there are nearly 3,000 new tables to be found, because the single single deletion is very slow, You now need to delete these tables with time information in bulk.
Theory&&measuretheory1 log in to the MySQL information database, find the tables table, find all the table names that meet the time requirements under the database where the table needs to be deleted2 Stitching the queried table names into the form of the drop table instruction data, for exampledrop table weekly_with_you_2014_12_28; 3 Log in to the MySQL Yc_market database and perform all the drop instructions from the previous step output
MeasureThe implementation is very simple, just need to enter the following command on the Linux terminal:[[email protected] ~]$ echo "Select Concat (' drop table ', table_name, '; ') From TABLES where Table_schema = ' yc_market ' and table_name like ' weekly_with_you_2014% '; "| mysql-uroot-p123456-h127.0.0.1 Information_schema | Sed-n ' 2, $p ' | mysql-uroot-p123456-h127.0.0.1 Yc_market
where Yc_marke is the database in which the table needs to be deletedThe sed command is used to skip the first line in all the resulting drop table directives, because the first row is invalid
MySQL Bulk Delete table