1.创建目录:
create or replace directory lobdir as '/home/dmdba/test';
2.创建表:
create table bfile_tab (bfile_column BFILE);
create table t (blob_column BLOB);
3.利用DBMS_LOB插入数据
declare
a_blob BLOB;
a_bfile BFILE := BFILENAME('LOBDIR','test.jpg');
begin
insert into bfile_tab values (a_bfile)
returning bfile_column into a_bfile;
insert into t 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;
4.查看数据:
select * from t;
向达梦数据库插入BLOB_第1张图片