Jump to content

Archived

This topic is now archived and is closed to further replies.

Ninjakreborn

blob or longtext

Recommended Posts

For larger amount's of text when saved within a database, is it better to use longtext, or blob datatypes.

Share this post


Link to post
Share on other sites
Well blob (which is the same as text) can only store just over 65,500 characters which is about 63KB of text. However longtext allows you to store dramatically more characters just under 4.3 trillion characters! Have a look at this [url=http://www.ilovejackdaniels.com/mysql_cheat_sheet.png]MySQL Cheat Sheet[/url] to see what each data types holds.
You'll probably want to use MEDIUMTEXT instead, which holds about 17 million characters, which is about 16MB.

1 character is a byte.

Share this post


Link to post
Share on other sites
There's other considerations to think about other than just how many bytes a data type will hold. For instance, if you ever plan on using full-text searches and create a full-text index, then use a text based data types instead of blobs. You can't create full-text indexes for blobs.

http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html

Share this post


Link to post
Share on other sites
If it's text, use TEXT... if it's binary data, use BLOB.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.