ZEROFILL
ZEROFILL is a MySQL attribute that pads the displayed value of numeric columns with zeroes up to the display width specified in column definition. It affects display only, not storage or calculations.
Example
Output
Explanation
In the above example, ZEROFILL
is used as a column option for the sample_id
column. This option zeroes are filled in the left until the specified length is met. On insert, if we insert a number that requires fewer digits than the field size, extra zeroes will be added on the left of the number. The result shows 00001
, 00042
, 00300
instead of 1
, 42
, 300
.