What is the difference between BLOB and CLOB datatypes?


Blob and Clob together are known as LOB(Large Object Type). The following are the major differences between Blob and Clob data types.

BlobClob
The full form of Blob is a Binary Large Object.The full form of Clob is Character Large Object.
This is used to store large binary data.This is used to store large textual data.
This stores values in the form of binary streams.This stores values in the form of character streams.
Using this you can stores files like videos, images, gifs, and audio files.
Using this you can store files like text files, PDF documents, word documents etc.
MySQL supports this with the following datatypes:
  • TINYBLOB

  • BLOB

  • MEDIUMBLOB

  • LONGBLOB

MySQL supports this with the following datatypes:
  • TINYTEXT

  • TEXT

  • MEDIUMTEXT

  • LONGTEXT

In JDBC API it is represented by java.sql.Blob Interface.In JDBC it is represented by java.sql.Clob Interface.
The Blob object in JDBC points to the location of BLOB instead of holding its binary data.The Blob object in JDBC points to the location of BLOB instead of holding its character data.
To store Blob JDBC (PreparedStatement) provides methods like:
  • setBlob()

  • setBinaryStream()

To store Clob JDBC (PreparedStatement) provides methods like:
  • setClob()

  • setCharacterStream()

And to retrieve (ResultSet) Blob it provides methods like:
  • getBlob()

  • getBinaryStream

And to retrieve (ResultSet) Clob it provides methods like:
  • getClob()

  • getCharacterStream()

Updated on: 07-Jun-2020

12K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements