Oracle保存图片到表

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
----------------------------------------------------
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

[@more@]保存
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/94041/viewspace-979951/,如需转载,请注明出处,否则将追究法律责任。
【Oracle保存图片到表】转载于:http://blog.itpub.net/94041/viewspace-979951/

    推荐阅读