What's the max length/number of chars in a mediumtext mysql field?
MEDIUMTEXT can store up to 16,777,215 characters i.e 16,777,215 bytes or 64MB of data. It is suitable for larger text strings like books, research papers, and code backup.
TINYTEXT is a string data type that can store up to to 255 characters. TEXT is a string data type that can store up to 65,535 characters. TEXT is commonly used for brief articles. LONGTEXT is a string data type with a maximum length of 4,294,967,295 characters.
Each LONGBLOB value is stored using a 4-byte length prefix that indicates the number of bytes in the value. A TEXT column with a maximum length of 4,294,967,295 or 4GB (232 − 1) characters. The effective maximum length is less if the value contains multibyte characters.
The standard TEXT data type object is sufficiently capable of handling typical long-form text data. TEXT data objects top out at 64 KB or 65,535 characters and requires a 2 byte overhead to store data.
While I think this question should have been answered by a simple Google search, I can't, realistically, vote to close under any of the existing options. As such I choose to offer an answer instead, in order that, hopefully, it won't be asked again and, if it is, subsequent questions may be closed as duplicates.
The maximum length of a 'mediumtext' field, in MySQL, is:
A string with a maximum length of 16,777,215 characters.
Or, according to the docs:
L + 3 bytes, where L < 224
You cannot make an assumption that 16,777,215 characters can be stored in a medium-text field. This depends on the character encoding, in some instances a single character can be comprised of more than one byte (wide characters or Unicode characters).
Checking the actual size in bytes remains the safest bet, especially if you want to develop a localized application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With