Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Max length of mediumtext? [duplicate]

Tags:

mysql

What's the max length/number of chars in a mediumtext mysql field?

like image 794
Ali Avatar asked Mar 08 '11 02:03

Ali


People also ask

How long is Mediumtext?

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.

What can be the maximum length of a text field?

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.

What is the maximum length of the long text data type?

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.

What is the maximum size of characters stored in a field declared with a text datatype BR?

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.


2 Answers

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

like image 53
2 revs, 2 users 95% Avatar answered Oct 05 '22 03:10

2 revs, 2 users 95%


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.

like image 20
Gerrit Brink Avatar answered Oct 05 '22 02:10

Gerrit Brink