Databases 5 min read

What Does the (10) in MySQL INT(10) Really Mean? Understanding Display Width and ZEROFILL

This article explains the meaning of the number in MySQL INT(10), how it controls display width with ZEROFILL, shows practical SQL examples, and details the deprecation of integer display width starting from MySQL 8.0.17.

ITPUB
ITPUB
ITPUB
What Does the (10) in MySQL INT(10) Really Mean? Understanding Display Width and ZEROFILL

1. Meaning

In MySQL, the number in parentheses after INT (e.g., INT(10)) specifies the display width, which only affects how values are padded with leading zeros when the ZEROFILL attribute is used. The storage size of INT is always 4 bytes (32 bits) regardless of the display width.

Storage space: INT always occupies 4 bytes.

Range: Signed INT: -2147483648 to 2147483647; INT UNSIGNED: 0 to 4294967295. Display width does not change this range.

2. Using ZEROFILL

When ZEROFILL is added to an INT column, MySQL pads the value with leading zeros to match the specified display width.

CREATE TABLE users (
  id INT(10) ZEROFILL,
  name VARCHAR(50)
);
INSERT INTO users (id, name) VALUES (123, 'Alice');
SELECT * FROM users;

The query returns the id as 0000000123, achieving a 10‑digit width.

3. Changes in MySQL 8.0.17 and later

Starting with MySQL 8.0.17, the display width for integer types is deprecated and ignored unless used with ZEROFILL. It is recommended to define INT without a width unless compatibility requires it.

Impact: INT(10) is ignored unless ZEROFILL is present.

Recommendation: Use plain INT.

Examples without ZEROFILL show that the width does not affect output, while with ZEROFILL the values are padded to the defined width.

4. Summary

The number in INT(10) is a display width used only with ZEROFILL to add leading zeros.

It does not affect storage size or numeric range.

From MySQL 8.0.17 onward, display width is deprecated; avoid relying on it unless necessary.

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.

SQLmysqlintZEROFILLdisplay width
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

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.