In my database I have declared a variable of datatype Int(10)
. If I type a number in a textbox in my web page, that number is stored in a variable whose largest value can be Int(10)
in Mysql. If I type a very large number in the textbox it is giving IndexOutofRangeException
.
So I am planning to use the maximumlength
property of text box. What is the maximum number that can be stored in a variable of type Int(10)
in mysql?
In MySQL integer int(11) has size is 4 bytes which equals 32 bit. Signed value is : - 2^(32-1) to 0 to 2^(32-1)-1 = -2147483648 to 0 to 2147483647. Unsigned values is : 0 to 2^32-1 = 0 to 4294967295.
The values int(1), int(6), int(10), and int(11) will have the maximum value in a range that equals 2147483647 (for signed INT) and 4294967295 (for unsigned INT).
Below the required storage and range for each integer type. An INT will always be 4 bytes no matter what length is specified.
INT(10)
means you probably defined it as INT UNSIGNED
.
So, you can store numbers from 0
up to 4294967295
(note that the maximum value has 10 digits, so MySQL automatically added the (10)
in the column definition which (10) is just a format hint and nothing more. It has no effect on how big number you can store).
You can use BIGINT UNSIGNED
if you want to store bigger values. See the MySQL docs: Integer Types (Exact Value)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With