I have to store an information into MySQL. Its length isn't fixed, it may be 255 or 2 figures lengthy. Must I use TINYTEXT or VARCHAR to be able to save space (speed does not matter)?

For data space for storage, VARCHAR(255) and TINYTEXT are equivalent:

VARCHAR(M): L + 1 bytes if column values require – 255 bytes, L + 2 bytes if values may need a lot more than 255 bytes.

TINYTEXT: L + 1 bytes, where L < 28.

Source: MySQL Reference Manual: Data Storage Requirements.


Space for storage being equal, you might want to browse the following Stack Overflow posts for more reading through on when you use either:

When utilizing VARCHAR, you have to specify most of figures that'll be saved for the reason that column. So, should you declare a column to become VARCHAR(255), this means that you could store text with as many as 255 figures. The key factor here is when you place two figures, only individuals two figures is going to be saved, i.e. allotted space is going to be 2 not 255.

TINYTEXT is just one of four TEXT types. They're much like VARCHAR, but you will find couple of variations (this is dependent on MySQL version you're using though). However for version 5.5, you will find some restrictions if this involves TEXT types. First the first is you need to specify a catalog prefix length for indexes on TEXT. And also the other the first is that TEXT posts can't have default values.

Generally, TEXT ought to be employed for (very) lengthy values. If you are using string which will have as much as 255 figures, then you need to use VARCHAR.

Hope this helps.