Search notes:

Oracle: SQL Loader example: Load binary data (blob)

This example tries to demonstrate how binary data (images) can be loaded into a blob.

Creating the table

A table with a blob is created:
create table tq84_sql_loader_blob (
   filename varchar2(20),
   author   varchar2(16),
   url      varchar2(80),
   image    blob
);
Github repository Oracle-Patterns, path: /SQLLoader/binary-data/create_table.sql

File list

The following file contains the file-names of the images to be loaded and some additional information that will also go into the destination table.
Binary-code.jpg|Christiaan Colen|https://ccsearch.creativecommons.org/photos/f63dd034-4de4-49c8-a500-270aedec50c5
Eschenbergturm.jpg|Nouhailler|https://ccsearch.creativecommons.org/photos/bb7d21fe-40de-46cb-a6e1-02df76cfa15a
Oracle-Buildings.jpg|Otto Gelderman|https://ccsearch.creativecommons.org/photos/53cbf2b7-0bc2-427a-abc3-cbf0413d9abb
Github repository Oracle-Patterns, path: /SQLLoader/binary-data/file-index.dat

Control (ctl) file

The control file, used by SQL*Loader, to load the data into the table.
load data
infile 'file-index.dat'
into    table tq84_sql_loader_blob
fields  terminated by '|'
(
   filename  char(20),
   author    char(16),
   url       char(80),
   image     lobfile(filename) terminated by eof
)
Github repository Oracle-Patterns, path: /SQLLoader/binary-data/load.ctl

Loading the data

The data load is triggered on a command line with something like
sqlldr control=load.ctl userid=rene/rene

See also

Loading binary data into long raw's
Other SQL Loader examples
SQL*Loader

Index