温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

BLOB 存入文件

发布时间:2020-07-20 16:16:05 来源:网络 阅读:1092 作者:00_yatou 栏目:关系型数据库
1.向blob字段插入文本
INSERT INTO lobdemo (key, clob_col, blob_col, bfile_col) VALUES (51, 'This is another character literal', HEXTORAW('ABABABABABABABABABAB'),  NULL);

2.更新blob字段文本
UPDATE peoplesoft  SET SUPPLIER_ID = HEXTORAW('CDCDCDCDCDCDCDCDCDCDCDCD') where rownum =2;
update PEOPLESOFT_1M set supplier_id = utl_raw.cast_to_raw(vendor_id) ;

3.向blob字段插入文件

CREATE TABLE yuser (ID number,photo BLOB);

create or replace directory images as '/test';

 declare
   l_bfile bfile;
   l_blob blob;
 begin
   insert into yuser(ID,photo) values(1,empty_blob())
   return photo into l_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_bfile bfile;
   l_blob blob;
 begin
   update yuser set photo = empty_blob() where id = 2
   return photo into l_blob;
   l_bfile:=bfilename('IMAGES','PS.pdf');
   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;
 、


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI