#1264超出范围值修复? [英] #1264 Out of range value fix?
问题描述
当我尝试将下面的内容插入我的MySQL时
When I try to insert the below into my MySQL
INSERT INTO `rooms` (`id`, `ip`) VALUES ('131213', '-259857341');
我因以下错误而失败:
Warning: #1264 Out of range value for column 'ip' at row 1
我环顾四周但还没找到如何解决或解决问题......
I am looking around but haven't found how to fix or work it out...
我的字段是无符号整数对于那个条目应该可以正常工作。
My field is unsigned int which should work just fine for that entry.
有什么问题,如何解决?
我使用unsigned int因为我想使用inet_ntoa / aton存储ips。
I am using unsigned int because I wanted to store ips using inet_ntoa/aton.
编辑:
我在MySQL网站上推荐使用unsigned INT:
I am using unsigned INT as recommend in MySQL website:
存储
INET_ATON()生成的值,使用INT UNSIGNED
列而不是INT,即
签名。如果使用带符号的列,则对应于IP地址
的
值(第一个八位字节大于
)不能正确存储。
请参见第10.6节超出范围和
溢出处理。
To store values generated by INET_ATON(), use an INT UNSIGNED column rather than INT, which is signed. If you use a signed column, values corresponding to IP addresses for which the first octet is greater than 127 cannot be stored correctly. See Section 10.6, "Out-of-Range and Overflow Handling".
http://dev.mysql.com/doc/refman/5.0/en/miscellaneous -functions.html
推荐答案
无符号整数至少表示非负值。
Unsigned integer means non-negative value at least.
不确定这是否是您所需要的,但您可以尝试将有符号整数转换为4字节无符号整数,如ipconverter所做的那样( http://www.silisoftware.com/tools/ipconverter.php ):
Not sure if this is what you need but you can try to convert signed integer to 4 bytes unsigned integer as your ipconverter does (http://www.silisoftware.com/tools/ipconverter.php):
INSERT INTO `rooms` (`id`, `ip`) VALUES ('131213', '-259857341' & 0xffffffff);
这篇关于#1264超出范围值修复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!