1: char in mysql
CHAR
The data type is a fixed-length character type in MySQL. We often declare CHAR
types whose length specifies the maximum number of characters to store. For example, CHAR(20)
it can hold up 20
to characters.
If the data to be stored is of fixed size, you should use a CHAR
data type. In this case you will get better performance compared to VARCHAR.
CHAR
The length of the data type can be any value from 0
to . 255
When storing a CHAR
value, MySQL pads its value with spaces to the declared length.
When querying for CHAR
values, MySQL removes trailing spaces .
Note: 1. The number of characters stored is 20, please pay attention to the number of bytes;
2. Store up to 20, or you can store 10, 11, etc.
2 : oarcle 中 char
char(20) ----> means: 20 bytes stored in oralce, when the number of digits is not enough, it will be supplemented with spaces. Whitespace is also not stripped when querying. Field values are formed together with spaces.
Special attention is required in designing the database. I used oracle a lot before, and now I use mysql. I have a deep understanding of the difference and the real usage of the two.