In this Oracle tutorial, we will learn about the raw datatype in the oracle database. Also, we will illustrate how to use it to create raw columns for a table in oracle.
Introduction to Oracle raw Datatype
The RAW datatype in Oracle 21c is a variable-length binary data type used to store binary data. It is often used to store binary data that cannot be easily converted into a character format, such as binary files or digital certificates.
Also, check: Char Datatype in Oracle Database
Oracle raw datatype Syntax
The syntax for declaring a column of raw datatype in Oracle 21c is as follows:
column_name RAW(size);
where column_name is the name of the column being declared as the RAW datatype and size is the maximum number of bytes allowed in the RAW data. The size can range from 0 to 32767.
Read: Oracle Blob Datatype
Oracle raw datatype Example
An example of using the RAW datatype in Oracle 21c is as follows:
CREATE TABLE binary_data (id NUMBER, binary_file RAW(4000));
In this example, we create a table called “binary_data” with two columns: “id” and “binary_file”. The “binary_file” column is of type RAW and can store binary data up to a maximum size of 4000 bytes.
Now we will insert the data into a following given table
INSERT INTO binary_data (id, binary_file)
VALUES (1, hextoraw('FFD8FFE0'));
select* from binary_data;

Now we will use the raw datatype in a SQL developer tool using oracle 21c.

In this given example, we create a table called “Customers” with two columns: “cust_id” and “product_details”. The “product_details” column is of type RAW and can store binary data up to a maximum size of 3000 bytes.
INSERT INTO customers (cust_id, product_details)
VALUES (672, hextoraw('74a5cfe'));
select* from customers;

Also, check: Clob Datatype in Oracle Database
Advantages of oracle raw datatype
- Storage efficiency: A RAW datatype is a good option for data storage because it uses the least amount of space to store binary data.
- Processing binary data quickly is made possible by the RAW datatype when compared to other datatypes like BLOB, CLOB, etc.
- Interoperability with other systems: The RAW datatype is a compatible choice for integrating data from many systems since it can be used to store binary data obtained from external systems.
- Little overhead: The RAW datatype is a practical option for storing binary data because it doesn’t require character set translation or validation.
- Simple to use and does not require additional handling, the RAW datatype is a straightforward solution for storing data.
Conclusion
So, in this Oracle tutorial, we understood how to define and use the 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.