innodb - MySQL auto increment column -
i see weird behavior auto-increment column number increasing in step of 2 instead of 1. end row ids 1, 3, 5, 7. use mysql 5.6 + innodb engine. idea why weirdness?
mysql> select version(); +-----------------+ | version() | +-----------------+ | 5.6.20-68.0-log | +-----------------+ 1 row in set (0.00 sec) mysql> show create table temp_table; | superset_version | create table `temp_table` ( `_id` int(11) not null auto_increment comment 'comm1', `name` varchar(100) not null comment 'comm2', `start_time` bigint(20) not null comment 'comm3', `updated_at` bigint(20) not null comment 'comm4', `status` varchar(50) not null comment 'comm5', primary key (`_id`) ) engine=innodb auto_increment=27 default charset=utf8 |
notice insert incremented _id
column difference of 2.
mysql> insert superset_version(name, start_time, updated_at, status) value("temp row", -1, -1, "erro"); query ok, 1 row affected, 1 warning (0.00 sec) mysql> select * superset_version order _id desc limit 3; +-----+----------+------------+------------+--------+ | _id | name | start_time | updated_at | status | +-----+----------+------------+------------+--------+ | 33 | temp row | -1 | -1 | erro | | 31 | temp row | -1 | -1 | erro | | 29 | temp row | -1 | -1 | erro | +-----+----------+------------+------------+--------+ 3 rows in set (0.00 sec)
auto_increment_increment setting set 2, therefore mysql increases auto increment numbers 2. use show varibles ... command check setting.
Comments
Post a Comment