bulk insert mysql - can i use ignore clause? is there a limit to no. of records for bulk insert?

我是研究僧i 提交于 2019-12-05 00:06:58

Yes, you can use the "ignore" keyword, and it will simply ignore duplicate errors. It will insert every row that it can, skipping those that would lead to duplicates (and it will not stop processing data.) If you do something like this (where we assume that the first column is a primary key):

insert ignore into c values (1,1), (2,2), (3,3), (3,5), (4,5);

Then that means that (3,3) will be inserted and (3,5) will not. Everything but (3,5) will be inserted (assuming a fresh table.)

There is probably no hard limit, but you might want to do testing to see where you should draw the line based on your needs.

Edit: It does seem that MySQL has a configurable limit on the size of SQL queries, with the default being 1MB. More info: http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_query_cache_limit.

There is also a limit of 50,000 rows an INSERT query may have.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!