问题
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>
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!
回答1:
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.
It appears when you try to enter 37364428662 it's defaulting to the largest possible value for an int 32 (2147483647).
回答2:
You want to insert a value for an id 37364428662 which is larger then the maximum allowed size of your integer field (2147483647).
来源:https://stackoverflow.com/questions/6498474/mysql-int-field-always-returning-the-same-value