Get the App
SLTechnology News&Howtos  ›  Database  › 

The maximum length of varchar in mysql database

Shulou Source: shulou.com Published: 2022-06-01 16:18:12 11月14日 Update

1, varchar storage rules: mysql4.0 version below, varchar (20), refers to 20 bytes, if you store UTF8 Chinese characters, only 6 (3 bytes each Chinese character) mysql5.0 version or more, varchar (20), refers to 20 characters, whether it is a number, letters or UTF8 Chinese characters (each Chinese character 3 bytes), can store 20, the maximum size is 65532 bytes.

2. Varchar is limited by encoding length rules: if the character type is gbk, each character is limited to 2 bytes, and the maximum length cannot exceed 32766.

If the character type is utf8, each character is up to 3 bytes and the maximum length cannot exceed 21845.

Varchar in mysql can store up to 65535 bytes of data.

The maximum length of a varchar is limited by the maximum row length (max row size,65535bytes). 65535 is not a very precise upper limit, and you can continue to reduce it. 65535 bytes include the length of all fields, the length identification of variable length fields (each variable length field uses an additional 1 or 2 bytes to record the actual data length), and the accumulation of NULL identification bits.

These are the details of the maximum length of varchar in mysql. For more information, please pay attention to other related articles!

Tags: Length byte maximum character Chinese character field data upper limit identification version type rule storage precision content size letter actual that is number Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei MySQL Shulou Tech Info Xiaomi Docker