跨不同数据库的MySQL MERGE表 [英] MySQL MERGE table across separate databases

查看:173
本文介绍了跨不同数据库的MySQL MERGE表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库 db1 ,其中包含表 tbl1 tbl2 tbl3

我也有一个空数据库 db2



我可以创建一个MERGE表 mrg1 ,它会合并数据库 db1 中的 tbl1 tbl2 tbl3 存储在数据库 db2

解决方案

是,如果您的数据库设置为允许您运行一次对多个数据库的查询。我认为它看起来像这样,

  INSERT INTO db2.mrg1(colA,colB,ColC)

SELECT colA,colB,ColC
从db1.tbl1,db1.tbl2,db1.tbl3
WHERE [无论如何连接你的表]


I have a database db1 which contains tables tbl1, tbl2, and tbl3.

I also have an empty database db2.

Can I create a MERGE table mrg1 which merges the contents of tbl1, tbl2, and tbl3 from database db1, but is stored in database db2?

解决方案

Yes, if your database is set up to allow you to run queries against multiple databases at once. I think it would look something like this,

INSERT INTO db2.mrg1 (colA,colB,ColC)
(
  SELECT colA,colB,ColC
  FROM db1.tbl1,db1.tbl2,db1.tbl3
  WHERE [whatever joins your tables together]
)

这篇关于跨不同数据库的MySQL MERGE表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆