What is BLOB Data Type?

By Saruque Ahamed Mollick

In this post, we are going to learn what is BLOB data type. Binary Large OBject also known as BLOB is a collection of binary data. But the data is stored as a single entity in a DBMS ( Database Management System ).

Generally, This type of data is used to store multimedia objects. ( Audio, Video, Images etc )

But one can also store binary code which is executable.

BLOB Data Type in MySQL

BLOB is a binary large object that can hold a variable amount of data.

There are four types of BLOB provided below:



  1. TIMYBLOB
  2. BLOB
  3. MEDIUMBLOB
  4. LONGBLOB

All of these BLOB’s general purpose is to store some binary data. But the only difference among these is the storage capacity of each BLOB.

The value of BLOB’s is treated as the binary string or you can also say byte string. They consist of a binary character set. Now if you want to apply any sorting to the BLOB’s value what will happen? The answer is – They will be sorted according to the numeric values of the bytes in the column values.

But one special point I would like to mention here, It is not allowed to set any default value for a BLOB. In simple words, You can’t define any default value for this type of data.

What is the maximum size of BLOB?

The maximum size depends on the type of the BLOB.

Though you should keep in mind that, the maximum value you can transmit between the client and server depends on the amount of available memory as well as the size of the communications buffers.

Reference: https://dev.mysql.com/doc/refman/8.0/en/blob.html

 

A BLOB family column is just like a VARBINARY and For BLOB columns there is no padding on insert and no bytes are stripped on select.

You can go through this below Java Program

How to convert BLOB to Byte Array in java

 

Leave a Reply

Your email address will not be published. Required fields are marked *