views:

761

answers:

4

Hi All,

Can one anyone provide any information on whether can we store normal text data(varchar) in mysql or sqlite Blob data type

+1  A: 

You can store any binary data in a blob. This would include both ascii and unicode text. However, you would need to explicitly interpret this as text in your code since an SQL interface would have no idea what type of data was stored inside its binary field.

Why would you want to use this rather than a normal varchar or text field?

Soviut
Thanks. I want do to this as the data i want to store in one column can come to db as img or normal text through an application.
MySQL DBA
You should probably have two nullable fields then; one for image data and one for text. If the data comes in with an image header, store it in the blob field, if it comes in as text, store it in the text field. Don't make columns try to store more than one type of data!
Soviut
+1  A: 

A BLOB is just a bunch of bytes -- no hindrance no help dealing with them in any way; a VARCHAR is known to be text so such things as character encoding and collation come into play. So, store bunches of bytes (e.g. images) as BLOBs, bunches of text as TEXT or VARCHAR!

Alex Martelli
A: 

in mysql you can insert text/varchar in a blob data type.

blob can support binary data. meaning that non binary or binary data are also supported in mysql.

text/varchar can be indexed but not for blob.

further readings here

Abu Aqil
A: 

SQLite uses manifest typing, so you can put any type of data in any type of column, actually. Then you'll have to interpret the returned data yourself, just like everyone pointed out for MySQL.

Mark Rushakoff