Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between the sql blob and image types

This question was actually posed to me this morning by one of my compadres, and it completely threw me, in so far as I didn't even realise SQL had an 'image' datatype so I've always simply gone down the route of compacting files/images etc into BLOB fields.

After having a (very) quick look around msdn the most I could really find was the info that the image datatype pages works like a blob or varbinary(max) up to a [max] size of ~2GB but past this can't seem to find too much more about it.

I'm wondering if maybe the image datatype is a way of providing indexable/searchable metadata on images within SQL...?

Does anyone have anything to offer, by way of links or explanations regarding this?

Any help would be gratefully received, so many thanks in advance of any replies!

UPDATE / Possible answer

After a little more digging I've perhaps acheived some headway with this...

It may well be that my original thoughts on what the "image" type relates to may have been somewhat misguided, maybe due to the type being titled "image" (which I apparently found quite misleading on first look) which I thought related to an image in a mimetype kinda way, but which appears to infer more of a "disk-image" or "binary-image" sort of idea.

In this way it seems that the IMAGE type was introduced to SQL before the varbinary type was allowed as a (max) field, possibly as a way of storing files in SQL in the way that is now taken for granted (by myself at least) with the use of VARBINARY(MAX)...

For Reference (both reasonably old but seem to fit the bill):

http://channel9.msdn.com/Forums/Coffeehouse/138883-Storing-Retrieving-images-from-SQL-Server-2005

http://www.basenow.com/help/Data_types_in_Microsoft_SQL_Server.asp

If anyone can offer any constructive crit on this possible answer that would be really useful in trying to understand this...

Cheers All!

like image 344
BizNuge Avatar asked May 25 '11 09:05

BizNuge


People also ask

What is image data type in SQL?

The IMAGE data type in SQL Server has been used to store the image files. Recently, Microsoft began suggesting using VARBINARY(MAX) instead of IMAGE for storing a large amount of data in a single column since IMAGE will be retired in a future version of MS SQL Server.

What is BLOB data type in SQL?

A BLOB (binary large object) is a varying-length binary string that can be up to 2,147,483,647 characters long. Like other binary types, BLOB strings are not associated with a code page.

Is an image a BLOB?

A binary large object (BLOB or blob) is a collection of binary data stored as a single entity. Blobs are typically images, audio or other multimedia objects, though sometimes binary executable code is stored as a blob.

Can BLOB store images?

A Binary Large Object ( BLOB ) is a MySQL data type that can store binary data such as images, multimedia, and PDF files.


1 Answers

It is vendor dependent but generally:

A blob/image data type is a column type which stores binary data in the database separate from rest of the columns. So everytime you ask for image/blob data, database looks up the location and reads the data and send back to you.

Some vendors do TEXT data type which is the same thing wit the the difference it accepts textual data so you can put full-text indexes on them.

like image 105
Aliostad Avatar answered Sep 25 '22 02:09

Aliostad