mysql identity属性_Mysql中Identity 详细介绍

假如表中包含一列为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;

<

版权声明:本文为weixin_31819459原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。