Tags

, , , , , , , , , ,

MySQL int(1) and int(11)

To be precise there is no difference between int(1) and int(11) in terms of storage space. Sometimes it seems like to have something with the storage space, but not exactly. Then what is the meaning in specifying int(1), int(11) etc ?

This is actually the specification of display width ! Display width is a number from 1 to 255. You can set the display width if you want all of your integer values to be visible. If you enable zerofill on the row, the field will have a default value of 0 for int(1) and 00000000000 for int(11). This has nothing to do with the memory usage as such.

An unsigned int has a max value of 4294967295, irrespective of int(1) and int(11).

If we need to save space usage, we need to carefully select the data-type for storage.

Advertisements