Upload File to Blob Column from TOAD
Table of contents
Blob Column Type in Oracle Database is a great way to store large binary data. In the Blob column, you can store large files like Audio, Video, Images, PDFs so on and so forth.
Although Content management solutions like UCM are the way to go to store Files, there may be scenarios where storing files onto database tables makes sense or lack of infrastructure is forcing us to take this route.
For the live Application, all the files that you wish to store on DB Table would be coming from the front end to the back end and ultimately to DB Tables.
However, for PoC or in a Dev environment, you might be looking to quickly upload the file to the blob column and run your test.
This is where the edit and upload feature provided by TOAD comes in handy. So let's create a table first and try to enter some data.
I'm using the TOAD 12.1 licensed version and the Oracle Database version is 19c.
Table Creation
We'll create a very simple table XX_DEMO
create table xx_demo (
id number primary key ,
text_value varchar2(100),
file_value blob
);
and insert some data into it whilst keeping file_value null
insert into xx_demo values (1 , 'Value 1' , null);
insert into xx_demo values (2 , 'Value 2' , null);
commit;
With this, our table creation is complete and sample data is loaded into it.
Uploading a file to column
To upload the file, we need to navigate to the Object Descriptor Window. To do so, we need to select the object name, in this case, it would be xx_demo. A window similar to below would appear.
Head over to the Data Tab, Select the column of the row for which you wish to upload a file and double-click on it
You'll see below a pop-up where you need to click on the highlighted icon to upload the file.
Once the file is uploaded, you'll see data length has changed. This means our file is uploaded to the column.
Let's close this window and commit our changes by clicking on the highlighted commit icon.
With this, we have committed our file to DB. Let's run a query to confirm whether our changes are persisted or not.
select a.* , length(file_value) from xx_demo a;
Below is the result of this query.
Conclusion
We have come to the end of this blog and we learned how we can upload files to a blob column using TOAD. If you are using SQL developer, take a look at Jeff's blog post to achieve the same result.
If you liked what you read, do consider following me.
I'm a Full Stack Developer and I'll be writing about my experiences in development and design on technologies like Spring Boot, Angular 2+, React, Node.js, REST APIs, SOAP Web services, Oracle Integration Cloud, Oracle ADF, SQL, PostGRE and many more.