Home > Database > Mysql Tutorial > What is the MySQL Equivalent of VARCHAR(MAX)?

What is the MySQL Equivalent of VARCHAR(MAX)?

Barbara Streisand
Release: 2024-12-01 07:58:10
Original
994 people have browsed it

What is the MySQL Equivalent of VARCHAR(MAX)?

Equivalent of Varchar(Max) in MySQL

In MySQL, the equivalent of VARCHAR(MAX) is VARCHAR(length) where length is subject to the maximum row size limit of 64KB (excluding BLOBs).

Using a multi-byte character set, however, reduces the maximum length due to encoding requirements: VARCHAR(21844) CHARACTER SET utf8.

Examples:

  • To declare a VARCHAR column with the max possible length (subject to row size) for a single-byte character set:

    VARCHAR(65532)
    Copy after login
  • For a multi-byte character set like UTF8:

    VARCHAR(21844) CHARACTER SET utf8
    Copy after login

Note that the maximum row size is calculated as the sum of the lengths of all columns in a row, including storage overhead. Therefore, it's impossible to declare a VARCHAR with a length equal to the maximum row size.

In summary, the equivalent of VARCHAR(MAX) in MySQL is VARCHAR(length), where the maximum length is determined by row size and character set encoding.

The above is the detailed content of What is the MySQL Equivalent of VARCHAR(MAX)?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template