What is TEXT data type in MySQL?

MySQLMySQLi Database

TEXT data objects are useful for storing long-form text strings in a MySQL database. Followings are some point about TEXT data type −

  • TEXT is the family of column type intended as high-capacity character storage.
  • The actual TEXT column type is of four types-TINYTEXT, TEXT, MEDIUMTEXT and LONGTEXT.
  • The four TEXT types are very similar to each other; the only difference is the maximum amount of data each can store.
  • The smallest TEXT type, TINYTEXT shares the same character length as VARCHAR.
  • TEXT values are treated as character strings.
  • TEXT has character set other than binary character set and collation.
  • The comparisons and sorting are based on the collation of its character set.
  • Truncation of excess trailing spaces from values to be inserted into TEXT columns always generates a warning, regardless of the SQL mode.
  • A TEXT family column is just like a VARCHAR.
  • TEXT column cannot have DEFAULT value.


 Following example shows how to declare a column as TEXT.

mysql> Create table magzine(id INT, title Varchar(25), Introduction TEXT);
Query OK, 0 rows affected (0.16 sec)

mysql> Describe magzine;
| Field        | Type        | Null | Key | Default | Extra |
| id           | int(11)     | YES  |     | NULL    |       |
| title        | varchar(25) | YES  |     | NULL    |       |
| Introduction | text        | YES  |     | NULL    |       |
3 rows in set (0.11 sec)
Published on 20-Feb-2018 10:11:31