+ 1

Int Default in MySQL

Hi fellow SoloLearners, If any of you out there are familiar with SQL databases, why does the int type doesn't require a size? For Instance: PD int NOT NULL does not require a parameter after int but INT(size) from W3Schools implies a size. From the looks of it, the () is optional for INT type.

10th Oct 2018, 8:28 PM
Apple Blossom
Apple Blossom - avatar
1 Answer
+ 1
According to what I read here: https://stackoverflow.com/questions/5634104/what-is-the-size-of-column-of-int11-in-mysql-in-bytes The *size* is used for formatting the number, the effect will be most obvious when the int field is defined with *size* and ZEROFILL option; it affects how many digits is printed of the number if the number digits is LESS THAN *size*. For example: Value Size Output 20 5 20 20 5 00020 (ZEROFILL enabled) 999999 5 999999 Notice that if number of digits of the number exceeds *size* the number will be shown as is, it will not be cropped to fit *size* definition (third example above).
15th Oct 2018, 7:31 AM
Ipang