MySQL Forums
Forum List  »  Newbie

Re: MySQL: Merge Databases
Posted by: Peter Brawley
Date: May 08, 2018 10:28AM

If A has only Inserts since the fork, and if each A table tracks Insert/Update date, say in a column named updated, all you need do for each table tbl table pair is something like ...

insert into b.tbl
select * from a.tbl
where date(a.updated)>'2018-03-01';

If there's no such column, but the tables have auto_increment PKs, then you'll need to collect the primary keys from A in a table, say ...

apks( tblname varchar(64), pkcolname varchar(64), pkval int ),

... then for each table with PK pkcolname you'll need something like ...

insert into b.tbl
select * from a.tbl
join a.pks as c on a.pkcolname = c.pkcolname and c.tblname = 'tbl'
where a.pkcolname > c.pkval;

Options: ReplyQuote


Subject
Written By
Posted
May 07, 2018 02:39PM
Re: MySQL: Merge Databases
May 08, 2018 10:28AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.