我们都知道处理LOB数据是很烦人的,在数据库设计完成后,我们常常需要装载测试数据,同样对于LOB很烦人,我们可以用sql*loader来实现, following is the control file:
Load DATA
INFILE *
INTO TABLE big_table
REPLACE
FIELDS TERMINATED BY X'09' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
xx__id INTEGER EXTERNAL,
xx_NAME char,
video_file filler char,
BEGINDATA
1 matrix3 martrix3.mpg
2 "Lord of ring" ring3.avi
3 "Top 10 of week" top10_3.ra
说明:
filler是loader的保留字,表示video_file是变量而不是字段名,filler char表示是字符串变量,为后面的lobfile使用
lobfile是loader的函数,表示该字段的值从lobfile取得
Load DATA
INFILE *
INTO TABLE big_table
REPLACE
FIELDS TERMINATED BY X'09' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
xx__id INTEGER EXTERNAL,
xx_NAME char,
video_file filler char,
video LOBFILE (video_file) TERMINATED BY EOF NULLIF value_file = 'NULL'
)BEGINDATA
1 matrix3 martrix3.mpg
2 "Lord of ring" ring3.avi
3 "Top 10 of week" top10_3.ra
说明:
filler是loader的保留字,表示video_file是变量而不是字段名,filler char表示是字符串变量,为后面的lobfile使用
lobfile是loader的函数,表示该字段的值从lobfile取得
TERMINATED BY EOF 表示每行的每个lob字段都来自一个独立的文件
===========
补充:
LOAD DATA INFILE 'lob_test_data.txt' INTO TABLE lob_tab FIELDS TERMINATED BY ',' (number_content CHAR(10), varchar2_content CHAR(100), date_content DATE "DD-MON-YYYY" ":date_content", clob_filename FILLER CHAR(100), clob_content LOBFILE(clob_filename) TERMINATED BY EOF, blob_filename FILLER CHAR(100), blob_content LOBFILE(blob_filename) TERMINATED BY EOF)