MySQL - how many rows can I insert in one single INSERT statement?

Luistar15 picture Luistar15 · Aug 21, 2010 · Viewed 110.7k times · Source

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

Answer

Lukman picture Lukman · Aug 21, 2010

You can insert infinitely large number of records using INSERT ... SELECT pattern, provided you have those records, or part of, in other tables.

But if you are hard-coding the values using INSERT ... VALUES pattern, then there is a limit on how large/long your statement is: max_allowed_packet which limits the length of SQL statements sent by the client to the database server, and it affects any types of queries and not only for INSERT statement.