I have recently delved into the exciting world of SQL. I am still trying to wrap my head around the concepts. I have been following tutorials online. Many of these tutorials
This additional "feature" display width is quite confusing, because in other column types like CHAR
is specifies the length.
Here is a short breakdown:
ZEROFILL
on a column with display width, and the string representation of the stored number is shorter than the display width, it will be left-padded with zeros. If it is longer, nothing happens. If you choose INT(5) and the value is 13, it will be returned as 00013. If the value is 123456 it will be returned as 123456.ZEROFILL
, there will be no padding at all (no spaces and such)ZEROFILL
, you must be aware that the column also will be UNSIGNED
I dislike the display width, because the storage layer is "knowing" about visual presentation of the stored data. Besides this, there is no use that I am aware of.