The number 1 used in parenthesis is only for width display. The INT(1) and TINYINT(1) does not influence the storage. The TINYINT takes 1 byte that means it has range -128 to +127 while int takes 4 bytes; it has range -2147483648 to +2147483647.
Data-wise, tinyint(1) , tinyint(2) , tinyint(3) etc. are all exactly the same. They are all in the range -128 to 127 for SIGNED or 0-255 for UNSIGNED . As other answers noted the number in parenthesis is merely a display width hint. You might want to note, though, that application=wise things may look different.
TINYINT − A very small integer that can be signed or unsigned. If signed, the allowable range is from -128 to 127. If unsigned, the allowable range is from 0 to 255. You can specify a width of up to 4 digits.
As far as I know, when you define INT(2) (where maximum value is 4), you are allocating in memory 2 bits, but if you insert value, which is bigger, then 4, MySQL will request more memory from system.
What is the maximum value allowed for a column of type tinyint(2)
?
Are values like 255 or 99 allowed? I am confused because (2)
after tinyint(2)
denotes only the display... Am I correct?
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