mysql 批量删除表数据

2015-09-23

 

#delete_table_data.sh
#批量删除mysql库中表数据 #
!/bin/bash ### AUTHOR: Leo ### DATE: 2015/09/23 ### REV: 1.0 echo -e "Input the dbname you want to use: \c" read db mysql -uroot -ppro#pateo -e "use $db;show tables;"|grep -v Tables>tb_in_$db.txt; for tb in `cat tb_in_$db.txt` do echo $tb; mysql -uroot -ppro#pateo -e "use $db;delete from $tb;select * from $tb;" echo '---------------------------------------'; done rm -rf tb_in_$db.txt;

 

posted @ 2015-09-23 17:22  岑亮  阅读(564)  评论(0编辑  收藏  举报