Oracle Blob Datatype

In this Oracle tutorial, we will learn about the Blob datatype in the oracle database. Also, we will demonstrate how to use it to create Blob columns for a table in oracle.

Introduction to Oracle Blob Datatype

The BLOB (Binary Large Object) data type in Oracle 21c is used to store binary data such as images, audio, and video files. This type of data is stored in binary format and can be larger in size than other data types like varchar2 or char.

Advantages of blob datatype

  • Large data storage: BLOB datatype can store binary data up to 4GB in size, making it suitable for storing large binary files like images and videos.
  • Binary data storage: BLOB data is stored in binary format, making it more efficient for storing and retrieving binary data than storing it as text or character data.
  • Compatibility with other data types: BLOB data can be converted to and from other data types, making it easy to work with other data in your database.

Also, check: Change Database Name in Oracle

Oracle blob datatype Syntax

The syntax for declaring a column of blob data type in Oracle 21c is as follows:

column_name BLOB;

Oracle blob datatype Example

Here’s an example of how you can create a table with a blob column in Oracle 21c.

CREATE TABLE employees (
  emp_id NUMBER,
  emp_name VARCHAR2(30),
  data BLOB

Now we will insert data into a table with a Blob column using the INSERT statement.

INSERT INTO employees ( emp_id, emp_name, data)
VALUES (1, 'Image 1', hextoraw('AABB'));
use blob datatype in oracle
use blob datatype in oracle

Read: Change Database Name in Oracle


Now we will use the blob datatype in a SQL developer tool.

blob datatype in oracle
blob datatype in oracle

Here we will insert the values into a customer table

INSERT INTO customers ( customer_name, customer_data)
VALUES ('Image 2', hextoraw('abba'));
insert values into a customer table
insert values into a customer table

Also, Check: How to copy a table in Oracle


So, in this tutorial, we understood how to define and use the blob Data type in Oracle 21c Database. And we have also covered a few sample examples related to it.

Also, take a look at some more Oracle tutorials.