Text column sizes in MySQL

Posted . Visible to the public.

Postgres works differently

See PostgreSQL: Difference between text and varchar columns for PostgreSQL-specific info

MySQL has 4 different column sizes. They are actually different data types under the hood:

type size limit schema.rb option
TINYTEXT 256 bytes size: :tiny
TEXT 65,535 bytes (default)
MEDIUMTEXT 16,777,215 bytes size: :medium
LONGTEXT 4,294,967,295 bytes size: :long

You can also specify a column size with the limit option. This will take an integer value in bytes and convert it to the next biggest available column type that can accommodate this amount of data.

Klaus Weidinger
Last edit
Klaus Weidinger
Source code in this card is licensed under the MIT License.
Posted by Klaus Weidinger to makandra dev (2024-04-23 12:40)