What's the difference between VARCHAR(255) and TINYTEXT string types in MySQL?
Each of them allows to store strings with a maximum length of 255 characters. Storage requirements are also the same. When should I prefer one over another?
What's the difference between VARCHAR(255) and TINYTEXT string types in MySQL?
Each of them allows to store strings with a maximum length of 255 characters. Storage requirements are also the same. When should I prefer one over another?
You cannot assign a DEFAULT
value to a TINYTEXT
and you cannot create an unprefixed index on the latter.
Internally, additional objects are allocated in memory to handle TEXT
(incl. TINYTEXT
) columns which can cause memory fragmentation on the large recordsets.
Note that this only concerns the column's internal representation in the recordsets, not how they are stored on the disk.
Using VARCHAR
you can set the column to NULL
or NOT NULL
and you can set DEFAULT
value, but not with TEXT
. Use VARCHAR
if you need one or both feature, NULL
and DEFAULT
.