The maximum length of the VARCHAR type of the MySQL database in versions below 4.1 is 255, and the data range can be 0 255 or 1 255 (depending on the version of the database). In versions above MySQL5.0, the vARCHAR datatype supports up to 65535 bytes, which means 65532 bytes of data can be stored. The start and end bits occupy 3 bytes, which means that the vARCHar datatype can hold up to 65535 bytes of data. Data that needs to be stored in fixed TEXT or BLOB format in version 4.1 or later can be stored in variable length VARCHAR, which can effectively reduce the size of database files. The vARCHAR type of MySQL database in versions below 4.1, nvARCHAR (store Unicode data type character), whether a character or a Chinese character, is stored in 2 bytes, usually used for Chinese or other language input, so it is not easy to garble; Varchar: Chinese characters are 2 bytes and other characters are 1 byte. Varchar is suitable for English and numbers. Under version 4.0, varchar(20) refers to 20 bytes. If you store UTF8 characters, you can only store 6 characters (3 bytes per character). Varchar (20), which refers to 20 characters, can store 20 characters regardless of numbers, letters or UTF8 Characters (each character is 3 bytes), the maximum size is 65532 bytes; Varchar (20) is a maximum of 20 bytes in Mysql4, but Mysql5 stores different sizes according to the encoding. A) Storage limitation The vARCHAR field stores the actual content separately from the cluster index. The content starts with 1 or 2 bytes to indicate the actual length (2 bytes if the length exceeds 255), so the maximum length cannot exceed 65535 bytes. B) Code length limit If the character type is GBK, each character can be 2 bytes at most and the maximum length cannot exceed 32766; If the character type is UTF8, each character can contain a maximum of 3 bytes and cannot exceed 21845 bytes. If the limit is exceeded, the VARCHAR field will be forced to text and warning will be generated. C) Line length limit causes the actual vARCHAR length limit to be the length of a row definition. MySQL requires that a row definition be no longer than 65535. ERROR 1118 (42000) is displayed if the length of the defined table exceeds this value: Row size too large. The maximum row size for the used table type, not counting BLOBs, Is 65535. You have to change some columns to TEXT or BLOBs.


The vachar field type in mysql can hold up to 65533 (when non-empty fields are not allowed) and 65532 (when non-empty fields are allowed) although the maximum length is 65535.