I have a column which is set to int(20)
when I try and insert a number like 622108120237
, it says it's out of range. Why?

- 2,825
- 4
- 33
- 49
-
possible duplicate of [How do I fix the 'Out of range value adjusted for column' error?](http://stackoverflow.com/questions/1786509/how-do-i-fix-the-out-of-range-value-adjusted-for-column-error) – Brad Werth Sep 16 '14 at 16:28
3 Answers
An int
, with MySQL, is stored on 4 bytes, and, as such, can only contain values between -2147483648
and 2147483647
.
622108120237
is greater than 2147483647
; so it doesn't fit into an int
-- looks like you are going to have to use a bigint
.
See the Datatypes - Numeric types section of
the MySQL manual, about that.

- 395,085
- 80
- 655
- 663
See the MySQL Numeric Type Documentation. These things are well-documented.
The range for a signed INT
is [-2147483648, 2147483647].
Note that in the case of INT(x)
, x is the "display width" and has nothing to do with the range or space requirements:
MySQL supports an extension for optionally specifying the display width of integer data types in parentheses following the base keyword for the type. For example, INT(4) specifies an INT with a display width of four digits ... display width does not constrain [or expand] the range of values that can be stored in the column.
Happy coding.
-
1Wow.. I thought Int(10) means.. 4Byte * 10 = 40Bytes.. I was wrong. Is is only applies for INT? How about the other types? – mazend Jan 31 '20 at 15:28
The maximum value you can store in an signed integer is 2147483647 And unsigned int is 4294967295 in Both case you exceed the limit

- 6,661
- 6
- 32
- 50