MySQL supports a very high number of data types, and choosing the right data type is critical to gaining performance.
Several principles for choosing a data type
1, smaller is usually better
2, simple is good, such as using Date,time,datetime to store time instead of string
3, try to avoid null, a field if you plan to build an index, you should try to design this field as not NULL
DATETIME and TIMESTAMP
The TIMESTAMP is smaller, but the allowed time range is small.
Integer type
TINYINT 8-bit storage space, SMALLINT 16-bit storage, mediumint 24-bit storage space,
INT 32-bit storage space, BIGINT 64-bit storage
The UNSIGNED property, which represents an unsigned data type that does not allow negative values, can increase the upper limit of a positive number by 1 time times.
Int (1) and int (20) are just a little different from the display of some MySQL command-line clients, and Int (1) and int (20) are the same for storage and computation.
VarChar saves storage space, but when you update, you need to do extra work.
Char is suitable for storing very short strings, or all values are close to the same length, such as the MD5 value
Char is also better than varchar for frequently changing data, because fixed-length char is not prone to fragmentation.
char (1) and varchar store only the values of Y and N, char (1) requires only 1 bytes, and varchar (1) requires two bytes.
Int (1) and int (20) are just a little different from the display of some MySQL command-line clients, and Int (1) and int (20) are the same for storage and computation.
High performance Mysql-schema and data type optimization