char/varchar-length in bytes or characters?
On some board, I read that *char
differs from *text
in that the first one measures the length of in characters, and the second one in bytes. That is, logically, char(255)
will write a string in Cyrillic to unicode is all 255 characters, and text(255)
should trim it to about half.
So here's the question: how many actual bytes will be allocated for fixed-type storage char(10)
compared to utf8_general_ci
? Where to find the truth?
char
are automatically converted to varchar
1 answers
Characters. Char, varchar, enum, text, and others are limited in length in characters. But general limits (for example, on the length of a row in a table, or the size of an index), can be additionally limited in bytes from above.
The direct text says in the manual:
For example, MySQL must reserve 30 bytes for a CHAR(10) CHARACTER SET utf8 column.
Char (10) in utf8_general_ci will take 30 bytes regardless of the written data.