SlideShare a Scribd company logo
Performing a mass-load of BLOBS                                                       Administration Tips




Mass-loading BLOBS into a table

Here's a real issue I had to deal with recently, and thanks to Anurag Varma
(avdbi@hotmail.com) who's a regular poster on the comp.databases.oracle.server
newsgroup and who proffered these techniques in response to my own pleas for help, I can
now share them with you.

My table was constructed thus:

CREATE TABLE ALBUM          (
PHOTOID NUMBER CONSTRAINT PHOTOID_PK PRIMARY KEY,
PHOTO BLOB);


...with a sequence and trigger to generate a unique number for each photo to be loaded:

CREATE SEQUENCE PHOTONUM;


CREATE OR REPLACE TRIGGER IDPHOTO
BEFORE INSERT ON ALBUM
FOR EACH ROW
BEGIN
         SELECT PHOTONUM.NEXTVAL
         INTO   :NEW.PHOTOID      FROM DUAL;
END;
10

So how best to load all 10000+ photos into the album table?

First, get a listing of all the files, and store it in a text file which we'll call photos.lst. Easy
enough: just type DIR /B /S D:PHOTOALBUM*.* > PHOTOS.LST in a DOS window.
Second, create a SQL Loader control file, which we'll call loadalbum.ctl, containing the
following lines:

LOAD DATA
INFILE PHOTOS.LST
INTO TABLE ALBUM
(EXT_FNAME FILLER CHAR(200),
PHOTO LOBFILE(EXT_FNAME) TERMINATED BY EOF)


Finally, run SQL Loader by typing the following command:

SQLLDR USERID=USERNAME/PASSWOIRD@TNSNAMES_ALIAS CONTROL=LOADALBUM.CTL




Copyright © Howard Rogers 2001                 10/18/2001                                      Page 1 of 2
Performing a mass-load of BLOBS                                                Administration Tips


You should find the thing now proceeds apace, and at the end of it, you should check the
SQL Loader log file for any errors that might have been encountered. That will be located
in a file called (in this case) loadalbum.log, located in the directory from which you
launched SQL Loader in the first place.

The principle lesson to be learned here is that SQL Loader is a fine tool for mass-loading
blobs into Oracle -a fact which I'd forgotten, and of which Anurag kindly reminded me.




Copyright © Howard Rogers 2001            10/18/2001                                    Page 2 of 2

More Related Content

Similar to Loadblobs

Editdmpfile
EditdmpfileEditdmpfile
Editdmpfile
oracle documents
 
Ryan Christiani I Heard React Was Good
Ryan Christiani I Heard React Was GoodRyan Christiani I Heard React Was Good
Ryan Christiani I Heard React Was Good
FITC
 
Corruptbkp
CorruptbkpCorruptbkp
Corruptbkp
oracle documents
 
Mc sl54 051_ (1)
Mc sl54 051_ (1)Mc sl54 051_ (1)
Mc sl54 051_ (1)
AnkitKumar2343
 
Sqllite
SqlliteSqllite
Sqllite
Senthil Kumar
 
Improving Drupal Performances
Improving Drupal PerformancesImproving Drupal Performances
Improving Drupal Performances
Vladimir Ilic
 
Drupal For Dummies
Drupal For DummiesDrupal For Dummies
Drupal For Dummies
Koen Delvaux
 
RMAN in 12c: The Next Generation (WP)
RMAN in 12c: The Next Generation (WP)RMAN in 12c: The Next Generation (WP)
RMAN in 12c: The Next Generation (WP)
Gustavo Rene Antunez
 
Missing redo logs in oracle
Missing redo logs in oracleMissing redo logs in oracle
Missing redo logs in oracle
Bolisetty Srinivas
 
WordCamp SF 2011: Debugging in WordPress
WordCamp SF 2011: Debugging in WordPressWordCamp SF 2011: Debugging in WordPress
WordCamp SF 2011: Debugging in WordPress
andrewnacin
 
Resolving Cached Design Element Corruption Issues in the IBM Notes Client
Resolving Cached Design Element Corruption Issues in the IBM Notes ClientResolving Cached Design Element Corruption Issues in the IBM Notes Client
Resolving Cached Design Element Corruption Issues in the IBM Notes Client
Devin Olson
 
Database architectureby howard
Database architectureby howardDatabase architectureby howard
Database architectureby howard
oracle documents
 
manifest file on SCORM 1.2
manifest file on SCORM 1.2manifest file on SCORM 1.2
manifest file on SCORM 1.2
aureliomld
 
Data recovery consistency with check db
Data recovery consistency with check dbData recovery consistency with check db
Data recovery consistency with check db
guesta1b3b39
 
Oracle business intelligence enterprise edition 11g
Oracle business intelligence enterprise edition 11gOracle business intelligence enterprise edition 11g
Oracle business intelligence enterprise edition 11g
uzzal basak
 
SugarCE For Small And Medium Enterprises
SugarCE For Small And Medium EnterprisesSugarCE For Small And Medium Enterprises
SugarCE For Small And Medium Enterprises
Dashamir Hoxha
 
Practicas oracle10g
Practicas oracle10gPracticas oracle10g
Practicas oracle10g
rehoscript
 
Alex Bolboacă: Usable Software Design at I T.A.K.E. Unconference 2015
Alex Bolboacă: Usable Software Design at I T.A.K.E. Unconference 2015Alex Bolboacă: Usable Software Design at I T.A.K.E. Unconference 2015
Alex Bolboacă: Usable Software Design at I T.A.K.E. Unconference 2015
Mozaic Works
 
Beginbackup
BeginbackupBeginbackup
Beginbackup
oracle documents
 
Nologging
NologgingNologging
Nologging
oracle documents
 

Similar to Loadblobs (20)

Editdmpfile
EditdmpfileEditdmpfile
Editdmpfile
 
Ryan Christiani I Heard React Was Good
Ryan Christiani I Heard React Was GoodRyan Christiani I Heard React Was Good
Ryan Christiani I Heard React Was Good
 
Corruptbkp
CorruptbkpCorruptbkp
Corruptbkp
 
Mc sl54 051_ (1)
Mc sl54 051_ (1)Mc sl54 051_ (1)
Mc sl54 051_ (1)
 
Sqllite
SqlliteSqllite
Sqllite
 
Improving Drupal Performances
Improving Drupal PerformancesImproving Drupal Performances
Improving Drupal Performances
 
Drupal For Dummies
Drupal For DummiesDrupal For Dummies
Drupal For Dummies
 
RMAN in 12c: The Next Generation (WP)
RMAN in 12c: The Next Generation (WP)RMAN in 12c: The Next Generation (WP)
RMAN in 12c: The Next Generation (WP)
 
Missing redo logs in oracle
Missing redo logs in oracleMissing redo logs in oracle
Missing redo logs in oracle
 
WordCamp SF 2011: Debugging in WordPress
WordCamp SF 2011: Debugging in WordPressWordCamp SF 2011: Debugging in WordPress
WordCamp SF 2011: Debugging in WordPress
 
Resolving Cached Design Element Corruption Issues in the IBM Notes Client
Resolving Cached Design Element Corruption Issues in the IBM Notes ClientResolving Cached Design Element Corruption Issues in the IBM Notes Client
Resolving Cached Design Element Corruption Issues in the IBM Notes Client
 
Database architectureby howard
Database architectureby howardDatabase architectureby howard
Database architectureby howard
 
manifest file on SCORM 1.2
manifest file on SCORM 1.2manifest file on SCORM 1.2
manifest file on SCORM 1.2
 
Data recovery consistency with check db
Data recovery consistency with check dbData recovery consistency with check db
Data recovery consistency with check db
 
Oracle business intelligence enterprise edition 11g
Oracle business intelligence enterprise edition 11gOracle business intelligence enterprise edition 11g
Oracle business intelligence enterprise edition 11g
 
SugarCE For Small And Medium Enterprises
SugarCE For Small And Medium EnterprisesSugarCE For Small And Medium Enterprises
SugarCE For Small And Medium Enterprises
 
Practicas oracle10g
Practicas oracle10gPracticas oracle10g
Practicas oracle10g
 
Alex Bolboacă: Usable Software Design at I T.A.K.E. Unconference 2015
Alex Bolboacă: Usable Software Design at I T.A.K.E. Unconference 2015Alex Bolboacă: Usable Software Design at I T.A.K.E. Unconference 2015
Alex Bolboacă: Usable Software Design at I T.A.K.E. Unconference 2015
 
Beginbackup
BeginbackupBeginbackup
Beginbackup
 
Nologging
NologgingNologging
Nologging
 

More from oracle documents

Applyinga blockcentricapproachtotuning
Applyinga blockcentricapproachtotuningApplyinga blockcentricapproachtotuning
Applyinga blockcentricapproachtotuning
oracle documents
 
Windowsosauthent
WindowsosauthentWindowsosauthent
Windowsosauthent
oracle documents
 
Whatistnsnames
WhatistnsnamesWhatistnsnames
Whatistnsnames
oracle documents
 
Whatisadatabaselink
WhatisadatabaselinkWhatisadatabaselink
Whatisadatabaselink
oracle documents
 
Varraysandnestedtables
VarraysandnestedtablesVarraysandnestedtables
Varraysandnestedtables
oracle documents
 
Usertracing
UsertracingUsertracing
Usertracing
oracle documents
 
Userpasswrd
UserpasswrdUserpasswrd
Userpasswrd
oracle documents
 
Userlimit
UserlimitUserlimit
Userlimit
oracle documents
 
Undo internalspresentation
Undo internalspresentationUndo internalspresentation
Undo internalspresentation
oracle documents
 
Undo internals paper
Undo internals paperUndo internals paper
Undo internals paper
oracle documents
 
Tablespacelmt
TablespacelmtTablespacelmt
Tablespacelmt
oracle documents
 
Tablerename
TablerenameTablerename
Tablerename
oracle documents
 
Sql scripting sorcerypresentation
Sql scripting sorcerypresentationSql scripting sorcerypresentation
Sql scripting sorcerypresentation
oracle documents
 
Sql scripting sorcerypaper
Sql scripting sorcerypaperSql scripting sorcerypaper
Sql scripting sorcerypaper
oracle documents
 
Sql for dbaspresentation
Sql for dbaspresentationSql for dbaspresentation
Sql for dbaspresentation
oracle documents
 
Sequencereset
SequenceresetSequencereset
Sequencereset
oracle documents
 
Rollbacksizes
RollbacksizesRollbacksizes
Rollbacksizes
oracle documents
 
Rollbackshrinks
RollbackshrinksRollbackshrinks
Rollbackshrinks
oracle documents
 
Rollbacklmt
RollbacklmtRollbacklmt
Rollbacklmt
oracle documents
 
Rollbackblocking
RollbackblockingRollbackblocking
Rollbackblocking
oracle documents
 

More from oracle documents (20)

Applyinga blockcentricapproachtotuning
Applyinga blockcentricapproachtotuningApplyinga blockcentricapproachtotuning
Applyinga blockcentricapproachtotuning
 
Windowsosauthent
WindowsosauthentWindowsosauthent
Windowsosauthent
 
Whatistnsnames
WhatistnsnamesWhatistnsnames
Whatistnsnames
 
Whatisadatabaselink
WhatisadatabaselinkWhatisadatabaselink
Whatisadatabaselink
 
Varraysandnestedtables
VarraysandnestedtablesVarraysandnestedtables
Varraysandnestedtables
 
Usertracing
UsertracingUsertracing
Usertracing
 
Userpasswrd
UserpasswrdUserpasswrd
Userpasswrd
 
Userlimit
UserlimitUserlimit
Userlimit
 
Undo internalspresentation
Undo internalspresentationUndo internalspresentation
Undo internalspresentation
 
Undo internals paper
Undo internals paperUndo internals paper
Undo internals paper
 
Tablespacelmt
TablespacelmtTablespacelmt
Tablespacelmt
 
Tablerename
TablerenameTablerename
Tablerename
 
Sql scripting sorcerypresentation
Sql scripting sorcerypresentationSql scripting sorcerypresentation
Sql scripting sorcerypresentation
 
Sql scripting sorcerypaper
Sql scripting sorcerypaperSql scripting sorcerypaper
Sql scripting sorcerypaper
 
Sql for dbaspresentation
Sql for dbaspresentationSql for dbaspresentation
Sql for dbaspresentation
 
Sequencereset
SequenceresetSequencereset
Sequencereset
 
Rollbacksizes
RollbacksizesRollbacksizes
Rollbacksizes
 
Rollbackshrinks
RollbackshrinksRollbackshrinks
Rollbackshrinks
 
Rollbacklmt
RollbacklmtRollbacklmt
Rollbacklmt
 
Rollbackblocking
RollbackblockingRollbackblocking
Rollbackblocking
 

Loadblobs

  • 1. Performing a mass-load of BLOBS Administration Tips Mass-loading BLOBS into a table Here's a real issue I had to deal with recently, and thanks to Anurag Varma (avdbi@hotmail.com) who's a regular poster on the comp.databases.oracle.server newsgroup and who proffered these techniques in response to my own pleas for help, I can now share them with you. My table was constructed thus: CREATE TABLE ALBUM ( PHOTOID NUMBER CONSTRAINT PHOTOID_PK PRIMARY KEY, PHOTO BLOB); ...with a sequence and trigger to generate a unique number for each photo to be loaded: CREATE SEQUENCE PHOTONUM; CREATE OR REPLACE TRIGGER IDPHOTO BEFORE INSERT ON ALBUM FOR EACH ROW BEGIN SELECT PHOTONUM.NEXTVAL INTO :NEW.PHOTOID FROM DUAL; END; 10 So how best to load all 10000+ photos into the album table? First, get a listing of all the files, and store it in a text file which we'll call photos.lst. Easy enough: just type DIR /B /S D:PHOTOALBUM*.* > PHOTOS.LST in a DOS window. Second, create a SQL Loader control file, which we'll call loadalbum.ctl, containing the following lines: LOAD DATA INFILE PHOTOS.LST INTO TABLE ALBUM (EXT_FNAME FILLER CHAR(200), PHOTO LOBFILE(EXT_FNAME) TERMINATED BY EOF) Finally, run SQL Loader by typing the following command: SQLLDR USERID=USERNAME/PASSWOIRD@TNSNAMES_ALIAS CONTROL=LOADALBUM.CTL Copyright © Howard Rogers 2001 10/18/2001 Page 1 of 2
  • 2. Performing a mass-load of BLOBS Administration Tips You should find the thing now proceeds apace, and at the end of it, you should check the SQL Loader log file for any errors that might have been encountered. That will be located in a file called (in this case) loadalbum.log, located in the directory from which you launched SQL Loader in the first place. The principle lesson to be learned here is that SQL Loader is a fine tool for mass-loading blobs into Oracle -a fact which I'd forgotten, and of which Anurag kindly reminded me. Copyright © Howard Rogers 2001 10/18/2001 Page 2 of 2