Core PHP

What Does int(11) mean in MySQL With Example

Generally people miss concept about what int(11) mean in MySQL is that the column can store maximum of 11 integer value or...

Written by Bikash · 1 min read >
What Does int(11) mean in MySQL With Example

Generally people miss concept about what int(11) mean in MySQL is that the column can store maximum of 11 integer value or digits in length. But this is not true.

int(11) means in MySQL is the display width of the integer column.

To completely understand the meaning of int(11) in MySQL and display the width of an integer column we use an example where we create a table with integer fields and values.

What Does int(11) mean in MySQL With Example
What Does int(11) mean in MySQL With Example

The example shows how the int(ANY_NUMBER) affects the value of that column.

What is the display width in MySQL?

Output:

what-is-display-width-in-mysql

Code Explanations:

  • On the above SQL query first, we create a table with 4 fields. One is auto-increment and the others are integer fields with its display width.
  • The V1 column has display width 2 including MySQL zero fill. You can see the value is 01, MySQL can auto-replace the display width 2 with one zero value.

MySQL int can be signed and unsigned, I show you the table which shows the required storage and range of other integer values.

TypeStorageMinimum ValueMaximum Value
(Bytes)(Signed/Unsigned)(Signed/Unsigned)
TINYINT1-128127
0255
SMALLINT2-3276832767
065535
MEDIUMINT3-83886088388607
016777215
INT4-21474836482147483647
04294967295
BIGINT8-92233720368547758089223372036854775807
018446744073709551615

Source: Integer Types (Exact Value) – INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT

Conclusion

Here we discuss what does int(11) means in MySQL completely with the help of an example. Than we check the other integer value’s storage and range with the help of a table.

I hope you all understand about the MySQL int(11).

Also Check:

Happy Coding..!

Was this article helpful?
YesNo
Written by Bikash
My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH. I am a web Programmer by profession and working on more than 50 projects to date. Currently I am working on the web-based project and all the CMS and frameworks which are based on PHP. Profile

One Reply to “What Does int(11) mean in MySQL With Example”

Leave a Reply

Your email address will not be published. Required fields are marked *