Search code examples
mysqlinnodb

TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT maximum storage sizes


Per the MySQL docs, there are four TEXT types:

  1. TINYTEXT
  2. TEXT
  3. MEDIUMTEXT
  4. LONGTEXT

What is the maximum length that I can store in a column of each data type assuming the character encoding is UTF-8?


Solution

  • From the documentation (MySQL 8) :

          Type | Maximum length
    -----------+-------------------------------------
      TINYTEXT |           255 (2 8−1) bytes
          TEXT |        65,535 (216−1) bytes = 64 KiB
    MEDIUMTEXT |    16,777,215 (224−1) bytes = 16 MiB
      LONGTEXT | 4,294,967,295 (232−1) bytes =  4 GiB
    

    Note that the number of characters that can be stored in your column will depend on the character encoding.