INT(1)
- I know, 1 does not mean 1 digit, it represents client output display format only.
but what does this signify
i have declared YEAR
as int(1)
, I still see all 4 bytes. please tell me what does INT(1)
means ?
SELECT * FROM TEST_USERDB;
+----+--------+------+
| ID | NAME | YEAR |
+----+--------+------+
| 1 | abcccc | 2012 |
| 2 | stack | 99 |
+----+--------+------+
In MySQL, INT(5) does not mean that values are limited to 5-character values. It only means that MySQL will try to pad these values with spaces/zeroes when returning them. The numeric range of any signed INT including INT(10), INT(5) or any other INT(n) is: -2,147,483,648 ... 2,147,483,647, which is 10 digits at most.
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 TINYINT takes 1 byte that means it has range -128 to +127 while int takes 4 bytes; it has range -2147483648 to +2147483647.
In MySQL “Where 1=1” results in all the rows of a table as this statement is always true. An example to better unerstand this statement is given as follows − First, a table is created with the help of the create command.
An
unsigned int
has the max value of4294967295
no matter if itsINT(1)
orint(10)
and will use 4 bytes of data.So, what does the number in the brackets mean? It pretty much comes down to display, its called the display-width. The display width is a number from 1 to 255. You can set the display width if you want all of your integer values to “appear”. If you enable zerofill on the row, the field will have a default value of 0 for
int(1)
and0000000000
forint(10)
.
Read more
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