mysql数据库重命名

wylc123 1年前 ⋅ 1460 阅读

假如源数据库名称为“srcdb”,目标数据库名称为"trgdb"

首先创建目标数据库:

create database trgdb;

查看源数据库中的所有表名:

use information_schema;

select table_name from TABLES where TABLE_SCHEMA= ‘srcdb’;

针对上面查询出来的表名,依次执行以下命令:

rename table srcdb.tablename1 to trgdb.tablename1;

这样源数据库srcdb中的表(表结构和表数据)就被全部迁移到目标数据库trgdb了。

更多内容请访问:IT源点

相关文章推荐

全部评论: 0

    我有话说: