MySQL批量导出包含前缀关键字的表
2,076 total views, 1 views today
1、查出满足条件的表,并确认没问题
条件1:表在db1数据库下; 条件2:包含前缀tmp_log_node_ ; 条件3:create_time <‘2019-01-01 00:00:00’)
1 |
mysql -uroot -p'xx' -D db1 -Bse "select table_name from information_schema.tables where table_schema='db1' and table_name like 'tmp_log_node_%' and create_time <'2019-01-01 00:00:00'" |
参数说明:
-B 批量处理
-s silent 静默,不输出标题和格式化符号
-e 执行命令
2、导出满足条件的表
1 |
mysqldump -uroot -p'xx' --single-transaction db1 $(mysql -uroot -p'xx' -D db1 -Bse "select table_name from information_schema.tables where table_schema='db1' and table_name like 'tmp_log_node_%' and create_time <'2019-01-01 00:00:00'") >/tmp/tmp_log_node_.sql |
One comment