> http://www.mysql.com/doc/n/o/node_357.html
>
> explains the different string data types and the storage requirements:
>
> Column Type             Storage required
> [...]
> VARCHAR(M)              L+1 bytes, where L <= M and 1 <= M <= 255
> [...]
> TINYBLOB, TINYTEXT      L+1 bytes, where L < 2^8
> [...]
>
> These two storage requirements are exactly the same, so isn't a TINYBLOB
> almost exactly like a VARCHAR(255) BINARY, and a TINYTEXT almost exactly
> like a VARCHAR(255)?
>
> There are some differences listed at:
> http://www.mysql.com/doc/B/L/BLOB.html
> Apparently, in MySQL 3.23.2, the only difference between a TINYTEXT and a
> VARCHAR(255) is that TEXT/BLOB fields can't have default values and
> trailing spaces are not removed as they are in VARCHAR values.  But are
> those really the only differences?

No. There's another small, but important difference: TEXT/BLOB fields
aren't stored directly in the row. Instead, a "pointer" is stored to
the data, which is located "somewhere else".

This is important where you have a lot of data stored in each row,
as each row is limited to about 64k. TEXT/BLOB fields only count
towards this limit with 1-4 bytes; a VARCHAR uses the L+1 bytes
as you write.

I assume that there is a small speed penalty in using TEXT/BLOB
fields, as compared to VARCHARs.

/ Carsten
--
Carsten H. Pedersen
keeper and maintainer of the bitbybit.dk MySQL FAQ
http://www.bitbybit.dk/mysqlfaq



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to