preface
Int (1); int(10); I did not answer well at that time, and I did not pay attention to it, so I made a note of it here.
To explore the
In mysql, the length of int can be set to 1, 255. When you enter a number less than 1, it automatically sets it to 11. When you enter a value greater than 255, you will be prompted for a maximum of 255. But it doesn’t really matter how much you set it, it’s the same as int (11). You set an int(1), you think it can only store 0 or 9, but it can store up to 11 digits. The storage range is from -2147483648 to 2147483647. So what is the function of the array specified after int? We can only see the effect when we add zerofill. If your int is set to int(4), when you store 1, then 0001 is displayed. From this we can conclude that the width after int is the width. The actual footprint is always 4 bytes. Note that do not use Navicat to explore, Navicat can not see the effect, use the console.
conclusion
Mysql int numbers are used only to show the length of the data, while float numbers limit the actual range of data. For example, float(3,2) can only write 0.00 to 999.99.
extension
The default values for MySQL int and tinyint are int(11) and tinyint(4), while Boolean actually stores tinyint(1).
Store the scope
The value types in the table above are fixed length, which means that no matter how large, large, or small the size of the value you store is fixed. For example, int(1), although M is 1 character, will always take up 4 bytes of space. In other words, you can store any number of signed integers from -2, 147, 483, 648 to 2, 147, 483, 647. Int (1) and int(11) take up 4 bytes and can store these numbers, tinyint(1) and tinyint(4) take up 1 byte and can store numbers from -128 to 127, which is why int(1) inserted 128 successfully in a previous experiment. The insertion of 128 by tinyint(1) indicates that the length is exceeded.
With the exception of Bigdeciaml, the maximum length is 255. Bigdecimal as follows