列的数据类型更改后的MySQL警告

时间:2011-08-03 06:03:04

标签: mysql types

我在MyISAM MySQL表上更改了一列的数据类型(超过350万条记录):

mysql> alter table `sometable` modify column `int_column` int(11) unsigned NOT NULL DEFAULT '0';

在此之前我的int_column是中等(8)。执行查询后,我收到377条警告。这是show warnings;查询结果:

mysql> show warnings;
+---------+------+----------------------------------------------------------+
| Level   | Code | Message                                                  |
+---------+------+----------------------------------------------------------+
| Warning | 1264 | Out of range value for column 'int_column' at row 19360   | 
| Warning | 1264 | Out of range value for column 'int_column' at row 33745   | 
| Warning | 1264 | Out of range value for column 'int_column' at row 181436  | 
| Warning | 1264 | Out of range value for column 'int_column' at row 587071  | 
| Warning | 1264 | Out of range value for column 'int_column' at row 596617  | 
| Warning | 1264 | Out of range value for column 'int_column' at row 659837  | 
| Warning | 1264 | Out of range value for column 'int_column' at row 668363  | 
| Warning | 1264 | Out of range value for column 'int_column' at row 801450  | 
| Warning | 1264 | Out of range value for column 'int_column' at row 827911  | 
| Warning | 1264 | Out of range value for column 'int_column' at row 835083  | 
| Warning | 1264 | Out of range value for column 'int_column' at row 853689  | 
| Warning | 1264 | Out of range value for column 'int_column' at row 867848  | 
| Warning | 1264 | Out of range value for column 'int_column' at row 922569  | 
| Warning | 1264 | Out of range value for column 'int_column' at row 922633  | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1002626 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1095119 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1102957 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1183077 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1282318 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1308876 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1311981 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1313329 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1375981 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1468411 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1470989 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1552848 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1556220 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1613484 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1619116 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1664449 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1670895 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1685828 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1689845 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1690212 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1697586 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1701220 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1710764 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1716681 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1717857 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1721820 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1721848 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1736543 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1738177 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1745430 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1748732 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1750112 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1753833 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1753903 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1762801 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1765664 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1766269 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1768134 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1786470 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1788247 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1790305 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1792769 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1795158 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1800610 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1806786 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1808764 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1820163 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1828066 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1842223 | 
| Warning | 1264 | Out of range value for column 'int_column' at row 1844030 | 
+---------+------+----------------------------------------------------------+ 
64 rows in set (0.26 sec)

问题很明显:我怎么可能为整数字段分配更多的字节,然后突然变成out of range

int_column上没有索引(我不知道它可能会有什么帮助。)

另一个问题是:为什么show warnings仅返回64行377?我很困惑。

谢谢。

1 个答案:

答案 0 :(得分:2)

您的旧数据类型已签名,您的新数据类型未签名。

所以你输了所有的负数。

显示警告对其存储的数量有限制。使用

SET max_error_count=....

要改变它。

BTW,无符号的int(11)太大,应该是int(10)。对于签名,由于减号,您可以有11个字符。