mysql int 字段总是返回相同的值 [英] mysql int field always returning the same value
问题描述
最近 MySQL 5.1.49 (OSX) 开始为名为 id
的所有整数字段插入相同的值2147483647"并设置为主键.所有数据库和所有表都会发生这种情况.这是一个简单的例子:
Recently MySQL 5.1.49 (OSX) started inserting the same value '2147483647' for ALL integer fields named id
and set as primary key. This is happening for all databases and all tables. Here's the a quick example:
mysql> INSERT INTO packages(id,name,rate) VALUES ('37364428662',"Testing","300");
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> SELECT * FROM packages;
+------------+---------+------+
| id | name | rate |
+------------+---------+------+
| 2147483647 | Testing | 300 |
+------------+---------+------+
1 row in set (0.00 sec)
mysql>
我正在尝试重新安装 MYSQL,因为似乎没有其他任何工作:/我将发布我管理的任何解决方案,但同时始终感谢任何帮助!
I'm attempting to re-install MYSQL as nothing else seems to be working : / I'll post any solutions I manage but meanwhile any help is always appreciated!
推荐答案
这可能是因为您的 id
字段是一个 32 位整数,而值 37364428662 需要超过 32 位来存储.尝试将 id
的类型更改为 unsigned int 或一些更大的整数类型.
It's probably because your id
field is a 32 bit integer and the value 37364428662 will require more than 32 bits to store. Try changing the type of id
to an unsigned int, or some larger integer type.
当您尝试输入 37364428662 时,它会出现默认为 int 32 (2147483647) 的最大可能值.
It appears when you try to enter 37364428662 it's defaulting to the largest possible value for an int 32 (2147483647).
这篇关于mysql int 字段总是返回相同的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!