1.先将待命名的数据库database_old里面的表从database_old.xxx都改名为database_new.xxx
select CONCAT(‘RENAME TABLE ‘,TABLE_SCHEMA,’.’,TABLE_NAME,’ to ‘, ‘database_new.’,TABLE_NAME,’;')
from information_schema.TABLES
where TABLE_SCHEMA = ‘database_old’;
2.将执行结果拷贝到一个sql里面,在database_new里面执行一遍。就可以了。非常快
RENAME TABLE database_old.table1 to database_new.table1;
RENAME TABLE database_old.table2 to database_new.table2;
…