Why if I create a varchar(65535), I get a mediumtext? Why if I create a varchar(65535), I get a mediumtext? mysql mysql

Why if I create a varchar(65535), I get a mediumtext?


I'm answering to my own question:

That's because I'm using a multi-byte character. If you use an utf-8 collation, you will not be able to create a varchar with about more than 21000 chars. But if you use ascii, you will.


According to mysql.com the length of mediumtext is L + 3 bytes. To me this means that if you have an empty field it will be 3 bytes. If you have an empty varchar the length of this field will be 1 byte.

Here is clearly mentioned

Prior to MySQL 5.0.3, a VARCHAR column with a length specification greater than 255 is converted to the smallest TEXT type that can hold values of the given length. For example, VARCHAR(500) is converted to TEXT, and VARCHAR(200000) is converted to MEDIUMTEXT. However, this conversion affects trailing-space removal.