ZEROFILL is specified in a column definition for numeric data types (TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT, DECIMAL, FLOAT, DOUBLE). When selected, numbers are returned as strings padded on the left with zeros so the total length equals the column’s display width. The attribute changes only the way data is displayed; internal storage remains unchanged. Because negative numbers would conflict with zero padding, MySQL automatically applies the UNSIGNED attribute whenever ZEROFILL is used.In MySQL 8.0 the numeric display width feature is deprecated and will be removed in a future release, but ZEROFILL continues to work as long as a display width is present. Migrating code to string functions such as LPAD is recommended for future-proofing.
MySQL 3.23
ZEROFILL pads numeric values with leading zeros to reach the specified display width and automatically sets the column to UNSIGNED.
The feature is deprecated in MySQL 8.0. It still works but may be removed, so migrate to LPAD or store identifiers as CHAR.
MySQL implicitly applies UNSIGNED when ZEROFILL is present to avoid conflicts between negative signs and leading zeros.
Use LPAD(CONVERT(num_col, CHAR), width, '0') in SELECT statements or store the identifier in a CHAR/VARCHAR column.