MEDIUMTEXT is one of the four MySQL TEXT family types (TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT). It is designed for medium-sized free-form character data such as blog posts, HTML documents, or JSON blobs that exceed the 65,535-byte limit of TEXT but do not require the 4-GB capacity of LONGTEXT.Storage and memory:- Each MEDIUMTEXT value uses L + 3 bytes, where L is the length of the stored string in bytes. The extra three bytes hold the length information.- The maximum length is 16,777,215 bytes (2^24 − 1).Character set and collation:- MEDIUMTEXT follows the column or table default character set unless explicitly overridden with CHARACTER SET and COLLATE clauses.- UTF-8 encoded MEDIUMTEXT can hold roughly 5.5 million 3-byte characters.Indexing:- MEDIUMTEXT columns cannot be used as a PRIMARY KEY.- When indexing, you must specify a prefix length (e.g., INDEX (column_name(255))).Limitations and caveats:- MEDIUMTEXT columns are not stored inline in some storage engines; large values may be stored off-page, which can affect performance.- MEDIUMTEXT is case-sensitive or case-insensitive depending on the chosen collation.- MEDIUMTEXT is not available in PostgreSQL, SQL Server, Oracle, or SQLite; equivalent types include TEXT, CLOB, or VARCHAR(max).
TINYTEXT, TEXT, LONGTEXT, MEDIUMBLOB, VARCHAR, BLOB, CLOB
MySQL 3.23 (1998)
MEDIUMTEXT can store up to 16,777,215 bytes. That equals 16 MB of data or roughly 5.5 million UTF-8 characters.
Use MEDIUMTEXT when your content regularly exceeds the 65 KB limit of TEXT but rarely surpasses 16 MB. If you expect larger data, pick LONGTEXT.
No. MEDIUMTEXT cannot serve as a PRIMARY KEY because MySQL does not permit keys on columns that may exceed index length limits.
Specify a prefix length: `CREATE INDEX idx_body ON blog_posts (body(255));`. Full-column indexing is not allowed.