Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT maximum storage sizes

Tags:

mysql

innodb

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?

like image 948
Lalith B Avatar asked Dec 18 '12 12:12

Lalith B


People also ask

What is the maximum size Mediumtext can hold?

MEDIUMTEXT: 16,777,215 - 16 MB The MEDIUMTEXT data object is useful for storing larger text strings like white papers, books, and code backup. These data objects can be as large as 16 MB (expressed as 2^24 -1) or 16,777,215 characters and require 3 bytes of overhead storage.

How many characters can Longtext hold?

LONGTEXT can store the maximum characters among all four, up to 4,294,967,295 characters i,e 4,294,967,295 bytes or 4GB. This is more than enough storage for any long-form text strings. For example, a book that MEDIUMTEXT can't hold can be stored using LONGTEXT.

What is the maximum size of text field data type?

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.


1 Answers

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.

like image 51
Bridge Avatar answered Oct 08 '22 20:10

Bridge