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 | |
+--------------+--------------+------+-----+-------------------+----------------+
After executing the below on an EMPTY table the primary key seems to be reset back to 1. Why is that? I thought that wasn't possible. This doesn't happen in 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_开发者_JAVA百科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 | |
+--------------+--------------+------+-----+-------------------+----------------+
Adding an index to an InnoDB table rebuilds the table. Not inheriting the old autoincrement value was a bug that's been fixed in your newer version.
http://bugs.mysql.com/bug.php?id=34920
http://bugs.mysql.com/bug.php?id=21404
精彩评论