Databases 10 min read

Do INT(4) and INT(11) Really Differ? MySQL INT Types Explained

This article investigates the meaning of the number in parentheses for MySQL INT types, demonstrates through storage tests that INT(4) and INT(11) have identical storage size and range, and explains how the ZEROFILL attribute changes only the displayed width.

Senior Brother's Insights
Senior Brother's Insights
Senior Brother's Insights
Do INT(4) and INT(11) Really Differ? MySQL INT Types Explained

Origin

When designing a MySQL database, developers often see integer columns defined as INT with a number in parentheses, such as INT(4) or INT(11), and wonder what the number actually controls.

Storage Comparison

Three tables— t_int_four, t_int_eleven, and t_int_default —were created, each containing a column of type INT(4), INT(11), and plain INT respectively. Inserting the maximum signed integer value 2147483647 succeeded in all three tables, showing that the parenthesized number does not limit the numeric range nor affect storage.

Attempting to store an 11‑digit number (e.g., 12345678901) in INT(11) also failed because the signed INT range remains limited to 10 digits; the display width does not extend the range.

Inspecting the .ibd files of the three tables revealed that each row occupies exactly 4 bytes, confirming that storage size is independent of the number in parentheses.

ZEROFILL

The ZEROFILL attribute converts an integer column to UNSIGNED and pads displayed values with leading zeros up to the specified width. A table t_int_zerofill with columns my_int_four, my_int_eleven, and my_int_default was created, each defined with ZEROFILL. Inserting the value 1 produced 0001, 00000000001, and 0000000001 respectively, matching the widths 4, 11, and the default unsigned width (10 digits). Inserting 1234 stopped padding for the INT(4) column because the number already reached the defined width, while the other columns continued to pad.

Mixed Example

A table t_int_complex_zerofill containing various numeric types (TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT) demonstrated that adding ZEROFILL does not change the actual storage size of any type; it only affects the visual representation.

Summary

The number in INT(M) is a display width, not a storage or range constraint. Without ZEROFILL, INT(4) and INT(11) behave identically—both occupy 4 bytes and share the same signed range. Developers may still write INT(11) as a visual cue that the column can hold up to the 10‑digit maximum of a signed INT, or use INT(4) to remind themselves of the 4‑byte storage size when optimizing table schemas.

INT(11): serves as a warning that inserting numbers longer than the signed INT’s 10‑digit maximum (e.g., 12345678901) would be illegal.

INT(4): indicates the column’s 4‑byte storage size, helping designers estimate overall row size alongside other column types.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

SQLmysqlDatabase designintstorageZEROFILL
Senior Brother's Insights
Written by

Senior Brother's Insights

A public account focused on workplace, career growth, team management, and self-improvement. The author is the writer of books including 'SpringBoot Technology Insider' and 'Drools 8 Rule Engine: Core Technology and Practice'.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.