达梦数据库对大对象类型的支持(clob、blob)

预置条件:

  1. 环境:达梦数据库已启动
  2. 数据库服务器创建/opt/bigdata目录,拷贝1.txt,2.png文件至该目录下;修改目录权限 :chown -R dmdba:dinstall /opt/bigdata

--创建大字段表

drop table if exists bigdata_test;

create table bigdata_test(filename varchar,file1 clob,png blob);

                            

create or replace directory images as '/opt/bigdata/';

insert into   bigdata_test values ('1',null,null);                      

--执行以下语句读取文件,进行更新

declare

 l_bfile bfile;

 l_bfile2 bfile;

 l_blob blob;

 l_clob clob;

begin

 update bigdata_test set png=empty_blob() where filename=1;

 update bigdata_test set file1=empty_clob() where filename=1;

 select png into l_blob from bigdata_test where filename=1;

 l_bfile:=bfilename('IMAGES','2.png');

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

 select file1 into l_clob from bigdata_test where filename=1;

 l_bfile2:=bfilename('IMAGES','1.txt');

 dbms_lob.open(l_bfile2,dbms_lob.file_readonly);

 dbms_lob.LOADCLOBFROMFILE(l_clob,l_bfile2,dbms_lob.getlength(l_bfile2),1,1,0,1,1);

 dbms_lob.close(l_bfile2);

 commit;

end;

--查看数据

select *from bigdata_test;

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值