天天看點

達夢資料庫對大對象類型的支援(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;

達夢資料庫對大對象類型的支援(clob、blob)
達夢資料庫對大對象類型的支援(clob、blob)