CREATETABLEyuser(IDnumber,photoBLOB); createorreplacedirectoryimagesas'/test'; declare l_bfilebfile; l_blobblob; begin insertintoyuser(ID,photo)values(1,empty_blob()) returnphotointol_blob; l_bfile:=bfilename('IMAGES','test.doc');--IMAGES是上面创建目录的大写 dbms_lob.open(l_bfile,dbms_lob.file_readonly); dbms_lob.loadfromfile(l_blob,l_bfile,dbms_lob.getlength(l_bfile)); dbms_lob.close(l_bfile); commit; end; /
update的方式
declare l_bfilebfile; l_blobblob; begin updateyusersetphoto=empty_blob()whereid=2 returnphotointol_blob; l_bfile:=bfilename('IMAGES','PS.pdf'); dbms_lob.open(l_bfile,dbms_lob.getlength(l_bfile)); dbms_lob.close(l_bfile); commit; end; 、