MySQL 修改数据库的Schema方法

来源:互联网 发布:新浪网络运营文职岗 编辑:程序博客网 时间:2024/05/29 17:16

话不多说,直接上脚本。

#!/bin/bashnew_database="new_db"ori_database="origin_db"database_password="newpass"mysql -uroot -p$database_password -e "create database if not exists $new_database"list_table=$(mysql -uroot -p$database_password -Nse "select table_name from information_schema.TABLES where TABLE_SCHEMA='$ori_database'")for table in $list_tabledo    mysql -uroot -p$database_password -e "rename table $ori_database.$table to $new_database.$table"done
0 0
原创粉丝点击