【发布时间】:2011-10-01 01:56:51
【问题描述】:
当我尝试将以下内容插入我的 MySQL 时
INSERT INTO `rooms` (`id`, `ip`) VALUES ('131213', '-259857341');
我失败并出现以下错误:
Warning: #1264 Out of range value for column 'ip' at row 1
我正在环顾四周,但还没有找到解决方法...
我的字段是 unsigned int,对于该条目应该可以正常工作。
问题是什么,我该如何解决?
我使用 unsigned int 是因为我想使用 inet_ntoa/aton 存储 ips。
编辑:
我在 MySQL 网站上推荐使用 unsigned INT:
存储由 INET_ATON(),使用 INT UNSIGNED 列而不是 INT,即 签。如果您使用带符号的列, 对应于 IP 地址的值 第一个八位组更大 超过 127 无法正确存储。 请参见第 10.6 节,“超出范围和 溢出处理”。
http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html
【问题讨论】:
-
在上面的问题上 ;)
My field is unsigned int which should work just fine for that entry.因为 -259857341 不超过最小值也不超过最大值。 -
int 字段有多少字节?参考:dev.mysql.com/doc/refman/5.0/en/numeric-types.html
-
您最初是如何提出负面 IP 的?你是在为某个平行宇宙编程吗?
-
@Flimzy 这不是我想出的 ip 我是从给我的一组文件中读取它,我必须将它解析到数据库中。
-
嗯,这个“ip”,不管它来自哪里,都不是真正的IP。 IP 不能为负数。
标签: mysql int outofrangeexception mysql-error-1264