当我测试intautoincrementingprimarykey的边界时,在mysql 5.6中可以看到
drop table if exists f1;
create table f1 (
i int(11) not null auto_increment,
primary key (`i`)
)ENGINE=InnoDB AUTO_INCREMENT=2147483640 DEFAULT CHARSET=utf8;
insert into f1 values (); -- execute this for 8 times
select * from f1;
+------------+
| i |
+------------+
| 2147483640 |
| 2147483641 |
| 2147483642 |
| 2147483643 |
| 2147483644 |
| 2147483645 |
| 2147483647 |
+------------+
2147483646的条目丢失。有人能解释为什么会有这种行为吗?
不使用自动增量,2147483646可以手动填充
drop table if exists f1;
create table f1 (
i int(11) not null ,
primary key (`i`)
)ENGINE=InnoDB AUTO_INCREMENT=2147483640 DEFAULT CHARSET=utf8;
insert into f1 values (2147483644),(2147483645),(2147483646),(2147483647);
select * from f1;
+------------+
| i |
+------------+
| 2147483644 |
| 2147483645 |
| 2147483646 |
| 2147483647 |
+------------+