oracle 操作bfile和blob
来源:互联网 发布:数据平台有哪些 编辑:程序博客网 时间:2024/05/22 15:22
--搞定big objects
--author:shine
--准备
--创建文件夹,授权
/*conn system/manager;
create directory test as 'D:/test';
grant read on direcotry test to scott;
conn scott/tiger;*/
create table test2
(
tid int,
t_file bfile,
t_lob blob
)
--BFILE
--write bfile
insert into test2(tid,t_file)
values(1,bfilename('TEST','/stuinfo.txt'));
commit;
--read bfile
declare
v_file bfile;
v_str raw(2000);
v_amount int default 1000;
begin
select t_file into v_file from test2 where tid=1; --从database中读出 (1.映射)
--v_file:=bfilename('TEST','/stuinfo.txt'); --直接从文件夹中取出
dbms_lob.open(v_file,dbms_lob.file_readonly); --(2.开文件)
dbms_lob.read(v_file,v_amount,1,v_str); --(3.读出)
dbms_output.put_line(utl_raw.cast_to_varchar2(v_str));
dbms_lob.fileclose(v_file); --(4.关文件)
end;
--BLOB
--write blob
declare
v_blob blob;
v_bfile bfile;
begin
insert into test2(tid,t_lob)
values(4,empty_blob())
return t_lob into v_blob;
v_bfile:=bfilename('TEST','/stuinfo.txt'); --(1.做个v_blob引用和v_file映射)
dbms_lob.open(v_bfile,dbms_lob.file_readonly); --(2.开文件)
dbms_lob.loadfromfile(v_blob,v_bfile,dbms_lob.getlength(v_bfile)); (3.把文件载入blob)
dbms_lob.fileclose(v_bfile); (4.关文件)
commit;
end;
--read blob
declare
v_blob blob;
v_amount int default 2000;
v_raw raw(3000);
begin
select t_lob into v_blob from test2 where tid=4; -- (1.取出blob)
dbms_lob.read(v_blob,v_amount,1,v_raw); --(2.读blob)
dbms_output.put_line(utl_raw.cast_to_varchar2(v_raw));
end;
select * from test2;
--CLOB和BLOB差不多只不过在读了时候,不用转了
总结一哈:
1、blob和bfile都可以读写large objects
2、bfile写容易(直接写),读难(要开文件啊,关文件..)
3、blob写难(要把bfile转到blob中才能写),读容易(和bfile无关,直接读)
- oracle 操作bfile和blob
- oracle bfile blob
- 操作BLOB、CLOB、BFILE
- oracle对大对象类型操作:blob,clob,nclob,bfile
- oracle对大对象类型操作:blob,clob,nclob,bfile
- oracle对大对象类型操作:blob,clob,nclob,bfile
- oracle对大对象类型操作:blob,clob,nclob,bfile
- Oracle BLob 与BFile数据类型的区别
- oracle中的大对象BLOB,CLOB,BFILE
- oracle 中CLOB与BLOB、BFILE
- 【转】oracle对大对象类型操作:blob,clob,nclob,bfile
- 【摘抄】oracle对大对象类型操作:blob,clob,nclob,bfile
- JDBC操作Oracle BFILE对象
- 【转】ORACLE BLOB BFILE 文件的录入及读取
- oracle中blob,clob,nclob,Bfile主要区别是什么? .
- oracle中blob,clob,nclob,Bfile主…
- oracle中blob,clob,nclob,Bfile主要区别
- clog、blob、bfile、long
- 不知不觉自己成了老程序员,却是刚刚想做职业规划。
- 批量转换Uncode编码的文件
- oracle 初识游标
- 用 FrontPage 服务器扩展配置 IIS
- 专家看台:软性方式留住人才,强悍团队的四个要素
- oracle 操作bfile和blob
- Lua
- Discuz!NT 邮件插件机制分析
- How to deploy a .Net assmebly for COM use through CAB on Web Page
- windows2003服务器官方视频教程
- 寒假计划
- 如何学习linux系统
- 再读《孙振耀撰文谈退休并畅谈人生》
- 信息备份--我的网络相关帐户信息