MySQL - how many rows can I insert in one single I

2020-01-26 05:23发布

Does it depend on the number of values sets? Does it depend on the number of bytes in the INSERT statement?

8条回答
啃猪蹄的小仙女
2楼-- · 2020-01-26 06:05

You will hit the max_allowed_packet limit and

error: 1390 Prepared statement contains too many placeholders.

You can put 65535 placeholders in one sql.So if you have two columns in one row,you can insert 32767 rows in one sql.

Import of 50K+ Records in MySQL Gives General error: 1390 Prepared statement contains too many placeholders

查看更多
做个烂人
3楼-- · 2020-01-26 06:12

You can insert an infinite number of rows with one INSERT statement. For example, you could execute a stored procedure that has a loop executed a thousand times, each time running an INSERT query.

Or your INSERT could trip a trigger which itself performs an INSERT. Which trips another trigger. And so on.

No, it does not depend on the number of value sets. Nor does it depend on the number of bytes.

There is a limit to how deeply nested your parentheses may be, and a limit to how long your total statement is. Both of these are referenced, ironically, on thedailywtf.com . However, both of the means I mentioned above get around these limits.

查看更多
登录 后发表回答