Home  >  Article  >  Database  >  In MySQL, when the VARCHAR data type will use 1 byte and when it will use the 2 byte prefixes length and data?length and data?

In MySQL, when the VARCHAR data type will use 1 byte and when it will use the 2 byte prefixes length and data?length and data?

王林
王林forward
2023-08-24 14:45:041481browse

在 MySQL 中,何时 VARCHAR 数据类型将使用 1 字节,何时使用 2 字节前缀 length 和 data?length 以及 data?

As we all know, in MySQL, VARCHAR values ​​are stored as 1-byte or 2-byte length prefix plus data. The length prefix indicates the number of bytes in the data value. The data value itself will determine when the VARCHAR data type uses a 1-byte prefix length and when a 2-byte prefix length is used.

  • If the value is not required, the column uses 1 byte longer than 255 bytes.
  • If the value may require more than 255 bytes, use a 2-byte length for the column.

The above is the detailed content of In MySQL, when the VARCHAR data type will use 1 byte and when it will use the 2 byte prefixes length and data?length and data?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete