tags:

views:

32

answers:

1

Hi,

I have a simple question that keeps me up all night :( . Suppose we have 2 databases on different servers. You can easily create 2 connections and manipulate data in both databases.

What if I want to execute one query on both databases? Example :

INSERT INTO database1.table1 
VALUES ( 'one','two','three') 
WHERE database1.table1.something LIKE (SELECT something from database2.table2)

Sorry for my code, I'm not really experienced with sql code. Such attempts are possible when the databases are all accessible through the same connection.

But is it possible to achieve the same result if the databases are on separate servers (when you need two connections) ?

It would be so much easier for me if such a solution would exist :( .

best regards

+1  A: 

Well, it's possible over one connection (Well, one connection from the client to one of the servers. There'll be connections from the server to the other servers). Just use the FEDERATED storage engine. It'll work the way you want (but beware it'll likely be quite slow due to all the added parsing and network traffic)...

ircmaxell
+1: I was just going to post the same thing - Oracle and SQL Server have the functionality to connect to other databases (including on other vendors). PostgreSQL 8.4 added dblink, but only supports connecting to other PostgreSQL instances...
OMG Ponies
Yeah, MySQL's only supports other MySQL servers. But I thought I saw somewhere a plugin engine that supports ODBC. I've found [FederatedX](http://capttofu.livejournal.com/21311.html), but that's not really much...
ircmaxell
Thx for the answer, I think that might just work. I tried it and it works exactly like the way I hoped. The speed is ok, I need it only for scheduled tasks on small tables anyway. Thx again