Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does INT(1) stand for in MySQL?

Tags:

mysql

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 |
+----+--------+------+
like image 501
chicharito Avatar asked Jul 19 '12 15:07

chicharito


People also ask

What does int 5 mean in MySQL?

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.

What is means by int 11 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.

What does the Tinyint 1 mean?

The TINYINT takes 1 byte that means it has range -128 to +127 while int takes 4 bytes; it has range -2147483648 to +2147483647.

What does where 1 mean in MySQL?

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.


1 Answers

An unsigned int has the max value of 4294967295 no matter if its INT(1) or int(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) and 0000000000 for int(10).

Read more

like image 178
Lion Avatar answered Oct 18 '22 01:10

Lion