0

I have two databases, each on a separate server. Each database has a number of similar but not identical tables. I need to combine the records from these similar tables into a new database, which is on one of the two servers.

SERVER A - Database 1

SERVER B - Database 2, Database 3 (new)

My thinking (as a relative novice re MySQL) is to first Insert existing records into the tables of the combined database, then use Insert|Update|Delete Triggers to maintain those records in the new db.

This would allow me to start with one roughly matching table from each of the two original databases, and gradually go through all the rest of the tables.

Is it possible to create Triggers on Database 1, which updates a table in Database 3 (new), which resides on a different server?

Any suggestions would be most welcome on how to accomplish this.

Colin 't Hart
9,52015 gold badges37 silver badges44 bronze badges
asked Aug 5, 2012 at 21:59
1
  • Are you familiar with INSERT INTO your_table (...) SELECT ... syntax? Commented Aug 5, 2012 at 22:13

2 Answers 2

2

There's the FEDERATED storage engine, which makes for a way to create a "proxy" table in your database server, which points to a real table on another server.

FEDERATED is disabled by default. To enable it, add this to your my.cnf configuration file, under the [mysqld] section:

federated = 1

So your trigger on some table T would then INSERT into your FEDERATED table FT, which would connect to the remote server, pass credentials, and perform the operation.

Do note the overhead: triggers are by themselves performance killers. Add to that the connection to the remote machine, and you now also have latency to worry about.

answered Aug 7, 2012 at 5:15
0

I don't think it is possible, especially on different servers, SGDB are not meant to connect to each other. But even if it was, that would not probably be the right way to go. If tables are not in the same database then they should not be dependent over one another.

You would be better off using either :

  • a batch that will continuously read the first 2 tables to update the 3rd,
  • or directly update it from the code that populates the first 2.
answered Aug 5, 2012 at 22:11

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.