RE: Lengtht of TEXT data types
> Hello list
>
> I have doubt on TEXT data types... Checking my notes I see these ones:
>
> TINYTEXT/TINYBLOB (2^8) 255 chars
> TEXT/BLOB (2^16) 64K chars
> MEDIUMTEXT/MEDIUMBLOB (2^24) 16M chars
> LONGTEXT/LONGBLOB (2^32) chars
>
> Well, my doubt consist on this... are these FIXED lengths for the text
> fields
> or they have variable length that may grow up to that as maximum?
>
> I require to store messages of variable length from 1 to 1024
> characters, so
> TINYTEXT is too short and TEXT is too large, so I want to know if it
> they
> have variable length analog to the VARCHAR type and the client program
> only
> ensures the messages to have 1024 length...
They are variable length. I believe they are assigned by blocks (disk
chucks, I believe), but I could be wrong on that part.
But in your case, you are safe using TEXT/BLOB. If you only store 1
byte, it's only taking 1 byte (plus a couple bytes overhead for the text
field). This is all covered somewhere on the MySQL site. Do a google
search on "mysql data type size" and you should find some additional
information.
|