E
E
ertaquo2013-04-05 14:16:22
MySQL
ertaquo, 2013-04-05 14:16:22

One table for two databases

Is it possible to have exactly the same tables in MySQL in multiple databases? Create a table in one database and somehow link it to other databases, or automatically update records in other tables, something like that?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Max, 2013-04-05
@ertaquo

dev.mysql.com/doc/refman/5.0/en/federated-use.html

U
Urvin, 2013-04-05
@Urvin

What's stopping you from doing this
SELECT * FROM scheme1.table1 JOIN scheme2.table2 USING (id) :

U
UZER2006, 2013-04-05
@UZER2006

If within the same server, you can, for example, put triggers on tables in each database for synchronization with other databases. Above you were told that you can make queries to different schemas.
But you have to manually maintain everything in case of adding or removing a database. That is, create, edit triggers ...
Or a federated table (also see the hint above).
If you synchronize copies on different servers, it is more difficult and impractical. I heard that in the latest versions of MySQL, you can run an external script on a trigger (which, in a particular case, will carry out the transfer of changes to other servers). But it will be necessary to keep the list of copies up-to-date, check for availability, take into account changes when a server crashes and synchronize after raising ... In general, not an option.
In any case, the structure of tables will have to be maintained completely manually.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question