Reputation: 146
I have problem. My MySQL DB automatically changes numbers that I have entered. For example my command goes
INSERT INTO `some_table` VALUES (`66477096289`)
and MySQL saves it as 2147483647
Field is int(16)
. I've tried to update it using phpMyAdmin, I got same result...
Upvotes: 0
Views: 900
Reputation: 2870
Use bigint, you are storing a large number which is exceeding the range
Upvotes: 0
Reputation: 644
MySQL ints are a signed 32bit integer. You're inserting a number that's far above the limit, so you're seeing the maximum possible integer, which is 2147483647.
Changed the data type to "bigint" for a 64bit data type, which'll handle your number.
Int value changes when insert into mysql database - php
Upvotes: 0
Reputation: 1141
The type INT
can only hold numbers up to 24147483647. As you are trying to insert a greater value, MySQL uses this maximum number instead.
If you want to store that number, use a bigger type, e.g. BIGINT
. See also MySQL Reference: Integer Types.
Upvotes: 0
Reputation: 12837
That is called overflow. You are trying to insert a bigger number than the column can hold. Try using a larger int type (i.e. bigint)
Upvotes: 0
Reputation: 1269623
You need to store the value as a bigint
or decimal
rather than a regular integer.
The number you are trying to save is 66,477,096,289. It is larger than the maximum signed or unsigned int.
Upvotes: 2