1.a -->b
#!/bin/bash
#先判断新数据库是否存在,要是不存在就创建。
#列出老数据库下都有那些表,其中N和s参数起到的作用是格式化,有点类似于Oracle下sqlplus里的pag
#用for循环来rename。
/bin/mysql -uroot -pjjjjj -h10.0.0.22 -e 'create database if not exists wxqyh_test_0704'
list_table=$(/bin/mysql -uroot -pjjjj -h10.0.0.22 -Nse "select table_name from information_schema.TABLES where TABLE_
SCHEMA='wxqyh_test'")
for table in $list_table
do
#echo $table
/bin/mysql -uroot -pjjjj -h10.0.0.22 -e "rename table wxqyh_test.$table to wxqyh_test_0704.$table"
done
[root@VM_0_134_centos 0704]#
参考:http://blog.itpub.net/20893244/viewspace-2147259/
用一个例子来演示会更加清晰