Mysql多次插入支持多少个扩展值?

标签 mysql

我们都知道在一个查询中使用多次插入比运行多个查询更好。但是,我不知道Mysql最多支持多少个这样的多个扩展值?我在网上搜索但没有找到正确的答案。我只是好奇地想知道这一点。

示例,

INSERT INTO tbl_name VALUES(1, 'John Doe'), (2, 'Peter England'), ....

我记得当我使用一些 MVC 框架时,它试图在一个查询中触发数百/数千个插入,我常常收到某种错误消息,例如 Mysql 服务器已消失

最佳答案

多次插入的限制,就像您所说的那样,会受到数据包限制的约束。

参见:http://dev.mysql.com/doc/refman/5.1/en/packet-too-large.html

这将影响所有查询类型,而不仅仅是插入。

为了添加更多上下文,您提到的错误 MySQL server has gone away将是超出数据包限制的结果。页面引用:

You can also get these errors if you send a query to the server that is incorrect or too large. If mysqld receives a packet that is too large or out of order, it assumes that something has gone wrong with the client and closes the connection. If you need big queries (for example, if you are working with big BLOB columns), you can increase the query limit by setting the server's max_allowed_packet variable, which has a default value of 1MB. You may also need to increase the maximum packet size on the client end. More information on setting the packet size is given in Section C.5.2.10, “Packet too large”.

关于Mysql多次插入支持多少个扩展值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11908880/

相关文章:

mysql - 从表中删除除一个和其他之外的重复项

java - java查看mysql查询结果

php代码拒绝将值插入数据库

mysql - 查询在 coldfusion 上下文中返回零记录,但在 Navicat 中工作正常

mysql - 无法连接到 AWS 中的 mysql

mysql - 子查询还是双重查询?

mysql - 关于mysql innodb mvcc的测试

java - Hibernate + Spring 从 MySQL 迁移到 SQL Server

php - 是否可以在 codeigniter 中用 where 条件计算所有?

php - Mysql 替换并删除旧条目