Oracle8i Application Developer's Guide - Large Objects (LOBs) Release 2 (8.1.6) Part Number A76940-01 |
|
Managing LOBs , 7 of 10
As mentioned earlier, LOB
data can be so large that it is reasonable to want to load it from secondary datafile(s).
In LOBFILE
s, LOB
data instances are still thought to be in fields (predetermined size, delimited, length-value), but these fields are not organized into records (the concept of a record does not exist within LOBFILES
); thus, the processing overhead of dealing with records is avoided. This type of organization of data is ideal for LOB
loading.
Each LOBFILE
contains a single LOB. For example:
LOAD DATA INFILE 'sample3.dat' INTO TABLE Multimedia_tab REPLACE FIELDS TERMINATED BY ',' ( Clip_ID INTEGER EXTERNAL(5), ext_FileName FILLER CHAR(40), Story LOBFILE(ext_FileName) TERMINATED BY EOF )
007,FirstStory.txt, 008,/tmp/SecondStory.txt,
Once upon a time ... The end.
Once upon another time .... The end.
Note::
|
In the control file, the size of the LOB
s to be loaded into a particular column is specified. During the load, any LOB
data loaded into that column is assumed to be the specified size. The predetermined size of the fields allows the dataparser to perform very well. Unfortunately, it is often hard to guarantee that all the LOB
s are the same size. For example:
LOAD DATA INFILE 'sample4.dat' INTO TABLE Multimedia_tab FIELDS TERMINATED BY ',' ( Clip_ID INTEGER EXTERNAL(5), Story LOBFILE (CONSTANT 'FirstStory1.txt') CHAR(32) )
007, 008,
Once upon the time ... The end, Upon another time ... The end,
LOB data instances in LOBFILE files are delimited. In this format, loading different size LOB
s into the same column is not a problem. The trade-off for this added flexibility is performance. Loading in this format is somewhat slower because the loader has to scan through the data, looking for the delimiter string. For example:
LOAD DATA INFILE 'sample5.dat' INTO TABLE Multimedia_tab FIELDS TERMINATED BY ',' (Clip_ID INTEGER EXTERNAL(5), Story LOBFILE (CONSTANT 'FirstStory2.txt') CHAR(2000) TERMINATED BY "<endlob>")
007, 008,
Once upon a time... The end.<endlob> Once upon another time... The end.<endlob>
Each LOB
in the LOBFILE
is preceded by its length. You can use VARCHAR
(see Oracle8 Utilities), VARCHARC
, or VARRAW
datatypes to load LOB data organized in this way. The controllable syntax for loading length-value pair specified LOBs is quite simple.
Note that this method of loading performs better than the previous one, but at the same time it takes some of the flexibility away, that is, it requires that you know the length of each LOB
before loading. For example:
LOAD DATA INFILE 'sample6.dat' INTO TABLE Multimedia_tab FIELDS TERMINATED BY ',' ( Clip_ID INTEGER EXTERNAL(5), Story LOBFILE (CONSTANT 'FirstStory3.txt') VARCHARC(4,2000) )
007, 008,
0031 Once upon a time ... The end. 0000
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|