id=1 name=...
id=2
id=6
After deleting the records with IDs 3, 4, and 5 inserted before, why is it not 3, but to 6
为情所困2017-05-16 13:15:37
You will know why if you use the command.
show create table test2;
The self-increasing value will not be reduced when you delete the record.
test2 | CREATE TABLE `test2` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`mouth` int(11) NOT NULL,
`num` int(11) NOT NULL,
PRIMARY KEY (`id`,`mouth`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=gbk
If you want to modify the self-increment value, please use sql to modify it
alter table test2 auto_increment=4;
The modified primary key auto-increment starting point.
test2 | CREATE TABLE `test2` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`mouth` int(11) NOT NULL,
`num` int(11) NOT NULL,
PRIMARY KEY (`id`,`mouth`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=gbk |
大家讲道理2017-05-16 13:15:37
You can refer to mysql auto-increment here, if you want that id
继续从3开始就要手动 INSERT INTO (id,字段2,字段2) VALUES ('3',值1,值2)