简体   繁体   中英

Import only latest changes from MYSQL dump file when importing

When importing a MySQL dump file from the staging server database to my local database it's taking too much time, is there any way that only the latest changes which are not there in the current local DB would be imported from the new dump file.

You have not supplied complete info. How big is the table? Are you replacing the entire table? Multiple tables? Are there FOREIGN KEYs ? Are you worried about blocking activity? What does "latest" mean?

If you are completely replacing one table (no FKs):

  1. Load the new data into a separate table.
  2. RENAME TABLE real TO old, new TO real;
  3. DROP TABLE old;

That won't speed things up, but will virtually eliminate any interference with the running table.

It is possible to 'incrementally' update a table.

  1. Load the new data into a separate table.
  2. INSERT/UPDATE/DELETE (3 separate queries) the new rows into the table. Use a SELECT... LEFT JOIN to see which rows are "new/changed/gone".

If you provide more details about your ultimate goals, I may have more details/tips.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM