MYSQL Replace entire table with another one

mysql

Solution

You can TRUNCATE (if you want to remove all existing data in db2), then INSERT:

TRUNCATE db2.tb;
INSERT INTO db2.tb SELECT * FROM db1.tb;

Problem

I am trying to achieve this. Say I have a two databases - db1 , db2. They each have a table called tb , the table structure is the same for both however, the records are different. Is there any elegant way I can replace all records inside db2.tb with the records from db1.tb. I think I can achieve this with php , but I`m looking for an elegant way.

Original source

Related problems