LInux下MySQL導出表(模糊查詢表名和指定表列表兩種方式)
1、模糊查詢表象
導出表名稱:
mysql -N information_schema -e "select table_name from tables where table_schema = 'dbname' and table_name like 'sys_%'" > tables.txt
root@serv: ~$ mysqldump dbname $(mysql -D YOURDBNAME -Bse "SHOW TABLES LIKE 'table_pattern_%'") > /tmp/database-dump.sql
2、指定表列表導出導出表名稱:
mysql -N information_schema -e "select table_name from tables where table_schema = 'dbname' and table_name like 'sys_%'" > tables.txt
導出表:
mysqldump dbname `cat tables.txt` >> dump_file.sql
批量刪除表:
mysql -NB information_schema -e "select table_name from tables where table_name like 'sys_%'" | xargs -I"{}" mysql dbname -e "DROP TABLE {}"
posted on 2016-07-02 09:01 草原上的駱駝 閱讀(2522) 評論(0) 編輯 收藏 所屬分類: Linux