Today, it is also a strange idea. MySQL verifies that varchar (15) will save 15 Chinese characters, and the first 15 will be automatically intercepted if the number exceeds 15. This concept may come from SQL server. In the varchar type, Chinese occupies two bytes. Therefore, only half of the varchar length can be saved in Chinese. However, in MySQL, both Chinese and English are length values, but the maximum length of varchar is different when different character encoding is selected for the database, however, the length of English and Chinese characters in the same encoding is the same.
In MySQL5, The varchar field type is described as follows: varchar (m) variable-length string. M indicates the maximum column length. M ranges from 0 to 65,535. (The maximum actual length of a VARCHAR is determined by the maximum row size and the character set used. The maximum valid length is 65,532 bytes ).
MySQL 5.1 complies with standard SQL specifications and does not delete trailing spaces of VARCHAR values. When VARCHAR is saved, it uses a prefix of one or two bytes plus data. If the length declared by the VARCHAR column is greater than 255, the length prefix is two bytes.
Well, it seems I understand a little bit. However, when the length is greater than 255, the prefix of two bytes is used. The primary subtraction question is: 65535-2 = 65533. I don't know how these Daniel calculate it. Do you still have questions?
Note: I tested UTF8 encoding. The maximum length of varchar is 21854 bytes.