The difference between database char and varchar: 1. The length of the char type is fixed, while the length of the varchar type is variable; 2. The data length of the char type is the same each time it is modified, and the efficiency is higher. The data length of the varchar type is different each time it is modified, and the efficiency is lower.
The difference between database char and varchar:
1. Different lengths
1. Char type: The length of char type is fixed.
2. Varchar type: The length of varchar type is variable.
2. Different efficiencies
1. Char type: The data length of the char type is the same each time it is modified, and the efficiency is higher.
2. Varchar type: The data length of the varchar type is different each time it is modified, and the efficiency is lower.
3. Different storage
1. Char type: When the char type is stored, it is the initial expected string plus a Record the length of the string in bytes, which takes up a lot of space.
2. Varchar type: The varchar type stores the actual string plus a byte recording the length of the string, which takes up less space.
Related learning recommendations: mysql video tutorial
The above is the detailed content of What is the difference between database char and varchar?. For more information, please follow other related articles on the PHP Chinese website!