The maximum length for the TEXT
data type in MySQL is 65535 characters. This is because TEXT
data types are stored using a two-byte length prefix that indicates the number of characters in the value.
Here is a summary of the different TEXT
data types in MySQL and their maximum lengths:
TINYTEXT
: 255 charactersTEXT
: 65535 charactersMEDIUMTEXT
: 16777215 charactersLONGTEXT
: 4,294,967,295 characters
Note that the actual maximum length of a TEXT
value may be less than the theoretical maximum, depending on the character set and collation used for the column. For example, if you use the utf8mb4
character set, which supports four-byte characters, the maximum length for a TINYTEXT
column will be reduced to 191 characters.
If you need to store longer strings, you can use the BLOB
data type, which has a maximum length of 4,294,967,295 bytes.