What is the size of column of int11 in mysql in bytes?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
MySQL is one of the most popular relational database management systems used for web applications and other software. One of the common questions when working with SQL databases is about the storage size requirements of various data types. This article delves into the storage size of the MySQL INT(11) data type, focusing specifically on the actual byte size required.
Understanding INT
In MySQL, the INT data type is used to store integer values. It's a versatile type that is widely used across different applications due to its ability to store both positive and negative whole numbers. However, one common misconception among new developers is the belief that INT(11) determines the number of bytes used to store the integer. In reality, this size refers to the display width and not the storage size.
INT Storage Requirements
Regardless of its display width (INT(1) up to INT(255)), the standard INT data type in MySQL always requires 4 bytes of storage.
- Signed Range: The value can range from -2,147,483,648 to 2,147,483,647.
- Unsigned Range: The value can range from 0 to 4,294,967,295.
INT(11) Explained
The (11) in INT(11) is meant to specify the display width of the field or the maximum number of digits that will be displayed by MySQL when using the ZEROFILL attribute. This display width makes sense in certain contexts but is often misunderstood as affecting the underlying storage requirement.
For instance, an INT(11) ZEROFILL would produce an output like 00000000001 for the value 1. However, the storage still remains at 4 bytes.
Technical Example
To illustrate this, you can create a sample table and insert values to see how they are stored and displayed:
Despite the display showing 11 digits, the size occupied by the value 1 in the database's physical storage is still 4 bytes.
Key Point Summary
To better understand the key aspects of INT(11), consider the following summary table.
| Attribute | Description |
| Storage Size | 4 bytes (standard for all INT data types) |
| Signed Range | -2,147,483,648 to 2,147,483,647 |
| Unsigned Range | 0 to 4,294,967,295 |
| Display Width | INT(11) defines how numbers are displayed, especially with ZEROFILL |
Additional Notes
- Display Width Usage: The display width has more utility with formats like
ZEROFILLwhich zero-pads numbers to the specified width, enhancing readability in certain applications. - Newer MySQL Releases: It's essential to recognize that newer versions of MySQL might deprecate certain features like
ZEROFILLand change the impact of display widths. Testing and checking with your application's MySQL version documentation is advised. - Optimization: While storage might not change with display width, optimizing column types (considering using smaller types like
TINYINTorSMALLINTwhen appropriate) can save space when aligned with the actual data range required.
Understanding the storage mechanisms of different data types helps optimize database usage, ensure portability, and increase efficiency in application development. Knowing that INT(11) does not affect the storage but only how data is displayed can clarify misconceptions and aid in better database design.

