If I don't know the length of a text entry (e.g. a blog post, description or other long text), what's the best way to store it in MYSQL?
views:
681answers:
2
A:
use TEXT if you want it treated as a character string, with a character set.
use BLOB if you want it treated as a binary string, without a character set.
I recommend using TEXT.
camflan
2008-09-29 20:56:30
+6
A:
TEXT would be the most appropriate for unknown size text. VARCHAR is limited to 65,535 characters from MYSQL 5.0.3 and 255 chararcters in previous versions, so if you can safely assume it will fit there it will be a better choice.
BLOB is for binary data, so unless you expect your text to be in binary format it is the least suitable column type.
For more information refer to the Mysql documentation on string column types.
Eran Galperin
2008-09-29 20:56:39