时间:2021-07-01 10:21:17 帮助过:34人阅读
mysql>create database db_v2; mysql>create database db_v2;
2.生成rename语句,从olddb里迁移,我这里olddb里sbtest;
mysql>select concat("rename table ",table_schema,".",table_name," to db_v2.",table_name,";") into outfile '/tmp/rename_to_db_v2.sql' from information_schema.tables where table_schema='sbtest'; mysql>select concat("rename table ",table_schema,".",table_name," to db_v2.",table_name,";") into outfile '/tmp/rename_to_db_v2.sql' from information_schema.tables where table_schema='sbtest';
3.执行生成的sql
mysql>source /tmp/rename_to_db_v2.sql mysql>source /tmp/rename_to_db_v2.sql
就这么简单可以搞定了。
Good luck!