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:
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'));
Read: Change Database Name in Oracle
Now we will use the blob datatype in a SQL developer tool.
Here we will insert the values into a customer table
INSERT INTO customers ( customer_name, customer_data) VALUES ('Image 2', hextoraw('abba'));
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.
- Oracle Timestamp Datatype
- Date Datatype in Oracle Database
- Char Datatype in Oracle Database
- Oracle Varchar2 Datatype
- Nchar Datatype in Oracle Database
- NVARCHAR2 Datatype in Oracle Database
- Float Datatype in Oracle Database
I am Bijay having more than 15 years of experience in the Software Industry. During this time, I have worked on MariaDB and used it in a lot of projects. Most of our readers are from the United States, Canada, United Kingdom, Australia, New Zealand, etc.
Want to learn MariaDB? Check out all the articles and tutorials that I wrote on MariaDB. Also, I am a Microsoft MVP.