碰到一个诡异的问题,大家看看:
mysql版本 5.5.25a, linux系统。
mysql> show create table a.b;
CREATE TABLE `b` (
`LOGICAL_SHARD_ID` int(11) NOT NULL,
`INVOICE_ITEM_ID` bigint(20) NOT NULL,
`INVOICE_ID` bigint(20) NOT NULL,
......
`REVENUE` decimal(24,10) DEFAULT NULL,
`STATUS` smallint(6) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
mysql> select count(*) from a.b;
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0.00 sec)
-- 表没有任何记录,是空表
mysql> ALTER TABLE a.b ADD CONSTRAINT PRIMARY KEY (`INVOICE_ITEM_ID`);
ERROR 156 (HY000): Table 'a.b#1' already exists
mysql> show warnings;
+-------+------+------------------------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------------------------+
| Error | 156 | Table 'a.b#1' already exists |
| Error | 1030 | Got error 156 from storage engine |
+-------+------+------------------------------------------------------+
2 rows in set (0.00 sec)
表已经存在,标的
--转自