MySQL 如何修复“为列调整的超出范围值”错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1786509/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I fix the 'Out of range value adjusted for column' error?
提问by zeckdude
I went into phpMyAdmin and changed the value for an integer(15)field to a 10-digit number, so everything should work fine. I entered the value '4085628851' and I am receiving the following error:
我进入 phpMyAdmin 并将整数 (15) 字段的值更改为 10 位数字,因此一切正常。我输入了值“4085628851”,但收到以下错误:
Warning: #1264 Out of range value adjusted for column 'phone' at row 1
警告:#1264 为第 1 行的“phone”列调整了超出范围的值
It then changes the value to '2147483647'.
然后将值更改为“2147483647”。
After some googling, I found this article that explains how to fix the problem. http://webomania.wordpress.com/2006/10/01/out-of-range-value-adjusted-for-column-error/, but I don't know how to login to the Mysql shell.
经过一番谷歌搜索,我发现这篇文章解释了如何解决这个问题。http://webomania.wordpress.com/2006/10/01/out-of-range-value-adjusted-for-column-error/,但我不知道如何登录到 Mysql shell。
How do I login to the Mysql shell? How do I fix this error?
如何登录Mysql shell?我该如何解决这个错误?
回答by martin clayton
The value you were trying to set is too large for a signed INT
field. The display width (15)
does not affect the range of values that can be stored, only how the value is displayed.
您尝试设置的值对于签名INT
字段来说太大了。显示宽度(15)
不影响可以存储的值的范围,只影响值的显示方式。
On phone numbers - see Is it better to store telephone numbers in some canonical format or "as entered"?
关于电话号码 - 请参阅以某种规范格式或“按输入方式”存储电话号码是否更好?
回答by zeckdude
I just changed the field type to BIGINT, and that fixed the problem. I guess i cant enter a value above 2147483647 for an INT, so I assume everyone who uses a field to enter a 10-digit phone number uses a BIGINT?
我只是将字段类型更改为 BIGINT,这解决了问题。我想我不能为 INT 输入大于 2147483647 的值,所以我假设使用字段输入 10 位电话号码的每个人都使用 BIGINT?
回答by Binu Raman
Best option for storing an integer of value bigger than 2147483647 would be to make the field type as BIGINT.
存储大于 2147483647 的整数值的最佳选择是将字段类型设为 BIGINT。
If it is for storing phone number, then way better is to store the value as a text field.
如果是用于存储电话号码,那么更好的方法是将值存储为文本字段。
回答by Dharsh_Thenu
you can try not giving the value that starts with'0'. If you want to begin the values with zero, then use varchar datatype
您可以尝试不提供以“0”开头的值。如果要以零开头的值,请使用 varchar 数据类型