How to update a large amount of data quickly

if you have a sku table with 10w or more data, how can you quickly get inventory from the second database to update sku inventory data?

Mar.25,2021

if your library 2 does not have a sku table, you can use the mysqldump command to export the sku table in library 1 to a file, and then import the data from this file into library 2:

.
$ mysqldump -uroot -proot --databases db1 --tables sku  >/tmp/sku.sql
$ mysql -uroot -proot db2 < /tmp/sku.sql

if you have sku tables in Library 2, and you just want to update data in Library 1 that is not available in Library 2, you must first pass insert. To operate with select statements, it is important to note that it is best not to insert 10w data at once, but to separate them according to certain conditions, such as id, because there are certain restrictions within mysql:

INSERT INTO db2.sku
SELECT * FROM db1.sku
where 
(db1.sku.id between 1 and 10000)
and (db2.sku);

INSERT INTO db2.sku
SELECT * FROM db1.sku
where 
(db1.sku.id between 10001 and 20000)
and (db2.sku);

I hope I can help you.

Menu