简体   繁体   English

如何通过 MySQL 查询将所有数据从一个模式插入到另一个模式?

[英]How to insert all data from one schema to another schema by MySQL queries?

I would like to copy all data from one schema (a) to another (b).我想将所有数据从一个模式 (a) 复制到另一个 (b)。 Two schemas have the same structure.两个模式具有相同的结构。

I use我用

Insert into a.table1 select * from b.table1;

But there are 254 tables in a and listing them is very frustrated.但是 a 中有 254 个表,列出它们非常令人沮丧。

Do you have any better solution?你有更好的解决方案吗?

Thanks谢谢

2 options... 2个选项...

1) Use dynamic SQL to loop through the results of: 1)使用动态SQL循环遍历结果:

select TABLE_NAME from information_schema.tables

2) Output the results of that query into excel, build your inserts from that then run them in a big old proc. 2) 将该查询的结果输出到 excel 中,从中构建您的插入,然后在一个大的旧 proc 中运行它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM