MySQL:跨位于不同服务器上的多个数据库的联接查询 [英] MySQL: Join Query Across Multiple Databases Located on Different Servers

查看:1857
本文介绍了MySQL:跨位于不同服务器上的多个数据库的联接查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在SQL Server中,有一种方法可以使用链接表从多个sql服务器中联接表.

In SQL Server there is a way to join tables from multiple sql servers by using link tables.

我想知道是否可以这样做?我正在使用PHP,PHP是否提供这种设施?

I wonder whether is it possible to do the same? I am using PHP, does PHP provides this kind of facilities?

推荐答案

这不一定容易,也不漂亮,但是本文为您的问题提供了一些解决方案: http://www.linux.com/archive/feature/52390

It isn't necessarily easy, nor pretty, but this article gives some solutions to your problem: http://www.linux.com/archive/feature/52390

更新

由于链接现在消失了,所以这里有更多文字

Since the link is gone now, here is more text

使用OLE DB for SQL Server创建链接服务器 此示例创建一个名为MyDatabase的链接服务器,该服务器使用用于SQL Server的Microsoft OLE DB提供程序.

Creating a linked server using OLE DB for SQL Server This example creates a linked server named MyDatabase that uses the Microsoft OLE DB Provider for SQL Server.

USE master
GO
EXEC sp_addlinkedserver 
'MyDatabase',
N'SQL Server'
GO

然后,您可以像将它们放在同一服务器上一样进行引用,因此,如果数据库在同一mssql服务器上,则跳过上述步骤,然后执行以下操作:

Then you can reference as though they are on the same server, so if the databases are on the same mssql server then skip the above step and just do the following:

[服务器名称].[数据库名称].[所有者] .table_name

[Server name].[database name].[owner].table_name

这篇关于MySQL:跨位于不同服务器上的多个数据库的联接查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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