小结:
1、日期类型按照date存储节省空间,仅3字节,而按照字符串型char 8字节 20190316 , varchar 20190316 9字节;
2、对于小于32768的整数,按照smallint仅仅为2字节,较字符型节约空间;
3、时间戳 1552187447 用int ,而非char(12);整数ip,长ip,用bigint;能数字,不字符型;
2019-03-16 20190316
https://dev.mysql.com/doc/refman/8.0/en/integer-types.html
Table 11.1 Required Storage and Range for Integer Types Supported by MySQL
Type | Storage (Bytes) | Minimum Value Signed | Minimum Value Unsigned | Maximum Value Signed | Maximum Value Unsigned |
---|---|---|---|---|---|
TINYINT |
1 | -128 |
0 |
127 |
255 |
SMALLINT |
2 | -32768 |
0 |
32767 |
65535 |
MEDIUMINT |
3 | -8388608 |
0 |
8388607 |
16777215 |
INT |
4 | -2147483648 |
0 |
2147483647 |
4294967295 |
BIGINT |
8 | -263 |
0 |
263-1 |
264-1 |
原文:https://www.cnblogs.com/yuanjiangw/p/10544050.html