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)
For a multi-byte character set like UTF8:
VARCHAR(21844) CHARACTER SET utf8
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!