Home > Database > Mysql Tutorial > 修改mysql数据库的库名

修改mysql数据库的库名

WBOY
Release: 2016-06-07 15:35:17
Original
1606 people have browsed it

假如源数据库名称为“srcdb”,目标数据库名称为trgdb 首先创建目标数据库: create database trgdb; 查看源数据库中的所有表名: use information_schema; select table_name from TABLES where TABLE_SCHEMA= ‘srcdb’; 针对上面查询出来的表名,依次执行

假如源数据库名称为“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了。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template