Equivalent of VARCHAR(MAX) in MySQL
The VARCHAR(MAX) data type in MySQL, which allows for unlimited text storage, does not have an exact equivalent. However, there are alternatives that provide similar functionality.
VARCHAR with Maximum Length:
The maximum length of a VARCHAR data type in MySQL is subject to the maximum row size, which is 64KB (excluding BLOB columns). To specify the maximum length for a VARCHAR column, use the following syntax:
VARCHAR(65535)
Character Set Considerations:
For multi-byte character sets, the limit is lower. For example, using the utf8 character set reduces the maximum length to:
VARCHAR(21844) CHARACTER SET utf8
Examples:
CREATE TABLE table_name ( column_name VARCHAR(65532) );
CREATE TABLE table_name ( column_name VARCHAR(21844) CHARACTER SET utf8 );
Note:
It's important to note that the maximum row size limit includes storage overhead for the VARCHAR column, so the actual maximum length may be slightly lower.
The above is the detailed content of What is the MySQL Equivalent of SQL Server\'s VARCHAR(MAX)?. For more information, please follow other related articles on the PHP Chinese website!