Mysql - Insert Millions of rows in chunk

时间:2019-05-19 04:02:55

标签: mysql stored-procedures mysql-workbench batch-processing bulkinsert

We need to insert 2 million rows in a table and what we are thinking to insert rows in a batch of 10000 rows each time, so that Mysql query won't excedded its size.

We are planning to insert 10000 rows each time using one query (shown below).

INSERT INTO table_name (column_list) VALUES (value_list_1), (value_list_2), ... (value_list_n);

If we go with a for loop approach how can we achieve this? Do we need to do something like this :

INSERT INTO table_name (column_list) SELECT (Column_list) FROM parent_table LIMIT 1, 10000

and this limit values we will be adjusting using For loop. Please suggest.

0 个答案:

没有答案