mysql> describe phppos_sales_suspended;
+--------------+--------------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+-------------------+----------------+
| sale_time | timestamp | NO | | CURRENT_TIMESTAMP | |
| customer_id | int(10) | YES | MUL | NULL | |
| employee_id | int(10) | NO | MUL | 0 | |
| comment | text | NO | | NULL | |
| sale_id | int(10) | NO | PRI | NULL | auto_increment |
| payment_type | varchar(255) | YES | | NULL | |
+--------------+--------------+------+-----+-------------------+----------------+
在EMPTY表上执行以下操作后,主键似乎重置为1.为什么会这样?我以为那是不可能的。这不会发生在mysql 5.1.54
中ALTER TABLE `phppos_sales_suspended` ADD `deleted` INT( 1 ) NOT NULL DEFAULT '0',
ADD INDEX ( `deleted` );
mysql> describe phppos_sales_suspended;
+--------------+--------------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+-------------------+----------------+
| sale_time | timestamp | NO | | CURRENT_TIMESTAMP | |
| customer_id | int(10) | YES | MUL | NULL | |
| employee_id | int(10) | NO | MUL | 0 | |
| comment | text | NO | | NULL | |
| sale_id | int(10) | NO | PRI | NULL | auto_increment |
| payment_type | varchar(255) | YES | | NULL | |
| deleted | int(1) | NO | MUL | 0 | |
+--------------+--------------+------+-----+-------------------+----------------+
答案 0 :(得分:1)
向InnoDB表添加索引会重建表。不继承旧的自动增量值是一个已在新版本中修复的错误。