MySQL auto_increment在大量INSERT之后变得疯狂

时间:2017-07-06 10:09:40

标签: mysql

我创建了一个带有自动增量PK的新表(my_new_table)。

SELECT `AUTO_INCREMENT`
FROM  INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'myschema'
AND   TABLE_NAME   = 'my_new_table';

结果:1,确定。

INSERT进入该表871来自另一个表的值。然后我做出这两个查询中的任何一个:

SELECT MAX(id) FROM my_new_table;
SELECT count(*) FROM my_new_table;

结果:871。确定。

但是当我再次检查AUTO_INCREMENT时:

SELECT `AUTO_INCREMENT`
FROM  INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'myschema'
AND   TABLE_NAME   = 'my_new_table';

结果:1024

为什么AUTO_INCREMENT值为1024而非872

提前致谢

1 个答案:

答案 0 :(得分:0)

由于这两个变量的$.ajax({ type: "get", url: "calling.php", data: "domnam="+domnam, success: function(msg){ var data = jQuery.parseJSON(msg); if(data.status == "error"){ // no need to check strictly return false; } } }); 2变量Mysqlauto_increment_increment值可能默认为1。你对价值做了任何改变。

所以请将此变量auto_increment_offset的值都设为 和auto_increment_increment auto_increment_offset

1

希望这会对你有所帮助。