Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How much difference does BLOB or TEXT make in comparison with VARCHAR()?

Tags:

sql

mysql

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?

like image 379
Rich Bradshaw Avatar asked Sep 29 '08 20:09

Rich Bradshaw


People also ask

What is the difference between BLOB and TEXT?

BLOB stands for Binary Large Objects and as its name suggests, it can be used for storing binary data while TEXT is used for storing large number of strings. BLOB can be used to store binary data that means we can store pictures, videos, sounds and programs also.

Is VARCHAR more efficient than TEXT?

In most circumstances, VARCHAR provides better performance, it's more flexible, and can be fully indexed. If you need to store longer strings, use MEDIUMTEXT or LONGTEXT, but be aware that very large amounts of data can be stored in columns of these types.

What is difference between VARCHAR and TEXT data type?

Some Differences Between VARCHAR and TEXT The VAR in VARCHAR means that you can set the max size to anything between 1 and 65,535. TEXT fields have a fixed max size of 65,535 characters. A VARCHAR can be part of an index whereas a TEXT field requires you to specify a prefix length, which can be part of an index.

Is VARCHAR Max a BLOB?

Overview of the VARCHAR(max) SQL Server Data Type. The SQL Server 2005 introduced this varchar(max) data type. It replaces the large blob object Text, NText and Image data types. All these data types can store data up to 2 GB.


1 Answers

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.

like image 86
Eran Galperin Avatar answered Oct 23 '22 07:10

Eran Galperin