方法一
E:photo>dir
Volume in drive E is New Volume
Volume Serial Number is F816-C39F
Directory of E:photo
2007-10-31 11:00 <DIR> .
2007-10-31 11:00 <DIR> ..
2007-08-13 16:19 1,212,681 flower.jpg
1 File(s) 1,212,681 bytes
2 Dir(s) 40,406,614,016 bytes free
----------------------------------------------------
SQL> conn a/a
Connected.
grant create any directory to a;
grant create any library to a;
create or replace directory photo_dir as ''e:photo'';
create table photos (blob_column blob);
declare
a_blob blob;
a_bfile bfile := bfilename(''PHOTO_DIR'',''flower.jpg'');
begin
insert into photos values (empty_blob()) returning blob_column into a_blob;
dbms_lob.fileopen(a_bfile);
dbms_lob.loadfromfile(a_blob,a_bfile,dbms_lob.getlength(a_bfile));
dbms_lob.fileclose(a_bfile);
commit;
end;
/
PL/SQL procedure successfully completed.
SQL> select dbms_lob.getlength(blob_column) from photos;
DBMS_LOB.GETLENGTH(BLOB_COLUMN)
-------------------------------
1212681
方法二,利用SQL*Loader
test.ctl
LOAD DATA
INFILE ''sample.dat''
append
INTO TABLE test
FIELDS TERMINATED BY '',''
(product_id INTEGER EXTERNAL(6),
FileName FILLER CHAR(30),
ad_graphic LOBFILE(FileName) TERMINATED BY EOF)
sample.dat
1,1.jpg,
2,2.jpg,
3,3.jpg,
4,4.jpg,
5,5.jpg,