Avatar of jazzIIIlove
jazzIIIlove
Flag for Sweden asked on

merging 2 mysql databases with java

Hi,

I need to merge 2 mysql databases with java or python.

The databases are exactly the same in schema but data is different.

in terms of the query which i need to pass in java or python. Anything i should care about?

Would it be the case that i need to insert data to the table having foreign key first?

what is the strategy?

Br.
MySQL ServerJavaPython

Avatar of undefined
Last Comment
CEHJ

8/22/2022 - Mon
CEHJ

I don't think there's a 'simple' way to do it. It's just a question of putting the work in
jazzIIIlove

ASKER
Hi,

But any approach you suggest?

Br.
CEHJ

You need to issue a series of queries for each and every table
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
jazzIIIlove

ASKER
Should i do this e.g
A) Table 2 fk (source): insert into Table 2' fk (target)

B) Table 1 pk (source): insert into Table 1' pk (target)

Should i do in this order (A, B)

Fk: foreign key, Pk: primary key

Prime tables are the tables that will have the merged data
CEHJ

Foreign keys would be a consideration if you are going to get referential integrity violations, yes. In that case, you need to do them in an order that doesn't cause violations
jazzIIIlove

ASKER
Do you think my above order is correct?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
CEHJ

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.