In this Oracle tutorial, we will learn about the Long raw data in the oracle database. Also, we will illustrate how to use it to create Long raw columns for a table in oracle.
Introduction to Oracle Long raw Datatype
In Oracle, binary big objects (BLOBs) of binary data are stored using the Long Raw datatype. Unstructured binary data, such as pictures, audio files, or video files, are stored there.
The Long Raw datatype, in contrast to the BLOB datatype, has no size restrictions and can contain a substantial quantity of binary data. Multimedia data is best stored using the Long Raw datatype.
Because LONG RAW has a less storage capacity than other data types like BLOB, it is rarely employed in modern database systems.
Also, check: How to create a user in Oracle
Oracle Long raw datatype Syntax
The syntax for declaring a Long Raw datatype in Oracle 21c is as follows:
column_name LONG RAW;
where column_name is the name of the column being declared as the LONG RAW datatype and size is the maximum number of bytes allowed in the LONG RAW data. The size of a LONG RAW data type in Oracle 21c can range from 0 to 2^32-1 bytes.
Read: How to copy a table in Oracle
Oracle Long raw datatype Example
An example of using the Long raw datatype in Oracle 21c is as follows:
CREATE TABLE my_table (
id NUMBER,
data LONG RAW
);
In this example, a table named my_table is created with two columns, id and data. The data column is of type LONGRAW, which can store binary data of variable length.
You can insert data into this table using the following statement:
INSERT INTO my_table (id, data)
VALUES (456, HEXTORAW('F1A5'));
select * from my_table;
In this example, the id column is set to 456 and the data column is set to the binary data F1A5 in hexadecimal format. The HEXTORAW function converts the hexadecimal string to a RAW data type.

Also, check: Oracle Varchar2 Datatype
Example:
Now we will use the Long raw datatype in a SQL developer tool using oracle 21c.
In this given example, we create a table called “Employees” with two columns: “emp_id” and “emp_data”. The “emp_data” column is of type LONG RAW.

Now we will insert the values into a following given table
INSERT INTO employees (emp_id, emp_data)
VALUES (864, hextoraw('FFD8FFE0'));
select * from employees;

Advantages of oracle Long raw datatype
The Long Raw datatype in Oracle is used to store large binary data, such as audio or video files, or large binary objects (BLOBs). The main advantage of using Long Raw is its ability to store large amounts of binary data without the need for additional storage management or compression.
This makes it ideal for storing unstructured or semi-structured data, as well as for preserving data integrity.
Another advantage of using Long Raw is its compatibility with other Oracle datatypes. For example, a Long Raw column can be directly linked to other tables, allowing data to be retrieved and processed efficiently.
Additionally, Long Raw is fully supported by Oracle’s programming language, making it easy to write procedures and functions that operate on Long Raw data.
Features of oracle Long raw datatype
- Small storage: Because a REAL data type only requires 4 bytes of storage, it is a good choice for large databases that require a lot of data.
- High accuracy: The REAL data type, which offers a high degree of precision, is suited for scientific or financial applications where precision is essential.
- Speed: The REAL data type is built for rapid processing, making high-performance computing applications a good fit for it.
- Because it is compatible with so many different programming languages, a REAL data type is a fantastic choice for developers that need to work with a variety of frameworks or languages.
- Usability: The REAL data type is easy to use, which is highly useful for developers who aren’t familiar with Oracle databases.
Conclusion:
So, in this Oracle tutorial, we understood how to define and use the Long raw Datatype in Oracle Database. And we have also covered a few sample examples related to it.
Also, take a look at some more Oracle tutorials.
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.