假如表中包含一列为auto_increment,
如果是myisam类型的引擎,那么在删除了最新一笔数据,无论是否重启mysql,下一次插入之后仍然会使用上次删除的最大id+1.
mysql> create table test_myisam (id int not null auto_increment primary key, name char(5)) engine=myisam;
query ok, 0 rows affected (0.04 sec)
mysql> insert into test_myisam (name) select ‘a‘;
query ok, 1 row affected (0.00 sec)
records: 1 duplicates: 0 warnings: 0
mysql> insert into test_myisam (name) select ‘b‘;
query ok, 1 row affected (0.00 sec)
records: 1 duplicates: 0 warnings: 0
mysql> insert into test_myisam (name) select ‘c‘;
query ok, 1 row affected (0.00 sec)
records: 1 duplicates: 0 warnings: 0
mysql> insert into test_myisam (name) select name from test_myisam;
query ok, 3 rows affected (0.00 sec)
records: 3 duplicates: 0 warnings: 0
mysql> select * from test_myisam;
<