操作blob该字段是否会产生很多redo,答案是否定的。以下来做一个实验,測试数据库版本号是11.2.0.1.0:

--创建一张表做測试之用

create table test_blob

(

  id number,

  tupian blob

);

import java.io.FileInputStream;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement; import oracle.sql.BLOB; public class BlobExample {
static final String driver_class = "oracle.jdbc.driver.OracleDriver";
static final String connectionURL = "jdbc:oracle:thin:@10.10.15.25:1521:orcl";
static final String userID = "test";
static final String userPassword = "test"; private void insertTestBlob() {
Connection conn=null;
Statement stm=null;
ResultSet rs=null;
BLOB blob = null;
FileInputStream fin=null;
OutputStream out=null;
try{
conn = DriverManager.getConnection(connectionURL, userID, userPassword);
stm = conn.createStatement();
conn.setAutoCommit(false);
String sql = "insert into test_blob values(1,EMPTY_BLOB())";
stm.executeUpdate(sql);
rs = stm.executeQuery("SELECT tupian FROM test_blob WHERE id=1 FOR UPDATE ");
fin = new FileInputStream("d://20130317.jpg");
byte[] blobBuf = new byte[(int)fin.available()];
fin.read(blobBuf);
fin.close(); if(rs.next()) {
blob = (oracle.sql.BLOB)rs.getBlob(1);
out = blob.getBinaryOutputStream();
out.write(blobBuf);
out.close();
conn.commit();
}
}catch(Exception e){
e.printStackTrace();
}finally{
try {
rs.close();
stm.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public static void main(String args[]){
BlobExample blobClobExample = new BlobExample();
blobClobExample.insertTestBlob();
}
}

--做非常多次

insert into test_blob  select * from test_blob;

insert into test_blob  select * from test_blob;

insert into test_blob  select * from test_blob;

.......

commit;

--准备dump block

select rowid,

       dbms_rowid.rowid_object(rowid) object_id,

       dbms_rowid.rowid_relative_fno(rowid) file_id,

       dbms_rowid.rowid_block_number(rowid) block_id,

       dbms_rowid.rowid_row_number(rowid) num

  from test_blob;

--update之前blob的状态

alter session set tracefile_identifier = 'Look_For_Me';

alter system switch logfile;

alter system switch logfile;

alter system dump datafile 5 block 3274932;

--update之后blob的状态,同一时候測试一下,此时update产生了多少redo

select name, value

  from v$mystat, v$statname

 where v$mystat.statistic# = v$statname.statistic#

   and v$statname.name = 'redo size'

update test_blob set tupian = null;

commit;

select name, value

  from v$mystat, v$statname

 where v$mystat.statistic# = v$statname.statistic#

   and v$statname.name = 'redo size'

alter system switch logfile;

alter system switch logfile;

alter session set tracefile_identifier = 'Look_For_Me1';

alter system dump datafile 5 block 3274932;

測试结果:我传的图片是5.1M,一共产生了350条数据,都把blob置为空以后,共产生了7.6M的redo。非常显然是blob的内容是没有产生redo的。

分析原理。得借助分析dump block的内容,能够看到设置blob字段为null后产生的redo仅仅是类似col  1: [84]这些信息。

blob设置为空曾经:

Block header dump:  0x0171f8b4

 Object id on Block? Y

 seg/obj: 0x17f1d  csc: 0x9a8.7256c728  itc: 2  flg: E  typ: 1 - DATA

     brn: 0  bdba: 0x171f8b0 ver: 0x01 opc: 0

     inc: 0  exflg: 0

 

 Itl           Xid                  Uba         Flag  Lck        Scn/Fsc

0x01   0x0003.01b.000033cf  0x00c001f5.132c.39  --U-    1  fsc 0x0000.7256c775

0x02   0x0000.000.00000000  0x00000000.0000.00  ----    0  fsc 0x0000.00000000

bdba: 0x0171f8b4

data_block_dump,data header at 0x2b35c4c56064

===============

tsiz: 0x1f98

hsiz: 0x14

pbl: 0x2b35c4c56064

     76543210

flag=--------

ntab=1

nrow=1

frre=-1

fsbo=0x14

fseo=0x1f12

avsp=0x1f29

tosp=0x1f29

0xe:pti[0] nrow=1
offs=0

0x12:pri[0] offs=0x1f12

block_row_dump:

tab 0, row 0, @0x1f12

tl: 91 fb: --H-FL-- lb: 0x1  cc: 2

col  0: [ 2]  c1 02

col  1: [84]

 00 54 00 01 01 0c 00 00 00 01 00 00 00 01 00 00 00 0e 48 41 00 40 05 00 00

 00 02 76 12 a0 00 00 00 00 00 02 01 71 f8 bc 01 71 f8 bd 01 71 f8 be 01 71

 f8 bf 01 71 f8 bb 01 ca 11 3d 01 ca 11 3e 01 ca 11 3f 01 ca 11 39 01 ca 11

 3a 01 ca 11 3b 01 ca 11 3c

LOB

Locator:

  Length:        84(84)

  Version:        1

  Byte Length:    1

  LobID: 00.00.00.01.00.00.00.0e.48.41

  Flags[ 0x01 0x0c 0x00 0x00 ]:

    Type: BLOB 

    Storage: BasicFile

    Enable Storage in Row 

    Characterset Format: IMPLICIT

    Partitioned Table: No

    Options: ReadWrite 

  Inode: 

    Size:     64

    Flag:     0x05 [ Valid InodeInRow(ESIR) ]

    Future:   0x00 (should be '0x00')

    Blocks:   630

    Bytes:    4768

    Version:  00000.0000000002

    DBA Array[12]:

      0x0171f8bc 0x0171f8bd 0x0171f8be 0x0171f8bf

      0x0171f8bb 0x01ca113d 0x01ca113e 0x01ca113f

      0x01ca1139 0x01ca113a 0x01ca113b 0x01ca113c

............................................................

............................................................

End dump data blocks tsn: 6 file#: 5 minblk 3274932 maxblk 3274932

blob设置为空之后:

Block header dump:  0x0171f8b4

 Object id on Block? Y

 seg/obj: 0x17f1d  csc: 0x9a8.7256c99f  itc: 2  flg: E  typ: 1 - DATA

     brn: 0  bdba: 0x171f8b0 ver: 0x01 opc: 0

     inc: 0  exflg: 0

 

 Itl           Xid                  Uba         Flag  Lck        Scn/Fsc

0x01   0x0003.01b.000033cf  0x00c001f5.132c.39  C---    0  scn 0x09a8.7256c775

0x02   0x0001.003.0000315e  0x00c0218e.1348.3a  --U-    1  fsc 0x0052.7256c9a7

bdba: 0x0171f8b4

data_block_dump,data header at 0x2b7ad6cce464

===============

tsiz: 0x1f98

hsiz: 0x14

pbl: 0x2b7ad6cce464

     76543210

flag=--------

ntab=1

nrow=1

frre=-1

fsbo=0x14

fseo=0x1f0c

avsp=0x1f29

tosp=0x1f7b

0xe:pti[0] nrow=1
offs=0

0x12:pri[0] offs=0x1f0c

block_row_dump:

tab 0, row 0, @0x1f0c

tl: 6 fb: --H-FL-- lb: 0x2  cc: 1

col  0: [ 2]  c1 02

............................................................

............................................................

End dump data blocks tsn: 6 file#: 5 minblk 3274932 maxblk 3274932

oracle 在操作blob该字段是否会产生很多redo的更多相关文章

  1. 【JDBC核心】操作 BLOB 类型字段

    操作 BLOB 类型字段 MySQL BLOB 类型 MySQL 中,BLOB 是一个二进制大型对象,是一个可以存储大量数据的容器,它能容纳不同大小的数据. 插入 BLOB 类型的数据必须使用 Pre ...

  2. oracle 下操作blob字段是否会产生大量redo

    操作blob字段是否会产生大量redo,答案是不会.以下来做一个实验,測试数据库版本号是11.2.0.1.0: --创建一张表做測试之用 create table test_blob (   id n ...

  3. Spring JDBC处理BLOB类型字段

    以下示例将演示使用spring jdbc更新BLOB类型的字段值,即更新student表中的可用记录. student表的结构如下 - CREATE TABLE student( ID INT NOT ...

  4. c# winform 操作oracle数据库的Blob字段,把图片存储到数据库,保存图片到数据库

    ///c# winform 操作oracle数据库的Blob字段,把图片存储到数据库,保存图片到数据库 闲话不多说,直接上代码 using System; using System.Collectio ...

  5. mybatis oracle BLOB类型字段保存与读取

    一.BLOB字段 BLOB是指二进制大对象也就是英文Binary Large Object的所写,而CLOB是指大字符对象也就是英文Character Large Object的所写.其中BLOB是用 ...

  6. [oracle] Oracle存储过程里操作BLOB的字节数据的办法,例如写入32位整数

    作者: zyl910 一.缘由 BLOB是指二进制大对象,也就是英文Binary Large Object的缩写. 在很多时候,我们是通过其他编程语言(如Java)访问BLOB的字节数据,进行字节级的 ...

  7. Oracle中,如何将String插入到BLOB类型字段

    1,String插入到BLOB类型字段,(这里的字符串以生成的XML为例): String XML = document.asXML();  //使用dom4j写成的xml是String类型,记得st ...

  8. panzer 电力项目十一--hibernate操作大文本字段Blob和Clob

    hibernate操作大文本字段Blob和Clob解决方案: 1.大文本字段Blob和Clob(流); 2.截串存取 第一步: 创建新表:Elec_CommonMsg_Content create t ...

  9. ORACLE日常操作手册

    转发自:http://blog.csdn.net/lichangzai/article/details/7955766 以前为开发人员编写的oracle基础操作手册,都基本的oracle操作和SQL语 ...

随机推荐

  1. [034] 微信公众帐号开发教程第10篇-解析接口中的消息创建时间CreateTime(转)

    从微信公众平台的消息接口指南中能够看出,每种类型的消息定义中,都包括有CreateTime參数,它表示消息的创建时间,例如以下图所看到的: 上图是消息接口指南中4.1-文本消息的定义.注意Create ...

  2. poj3617Best Cow Line

    题意大概是这样,给你一个字符串,你能够进行的操作是这种, 每次拿走这个串的第一个字母,或者最后一个字母,然后放到 一个新串的末尾(当然啦,新串一開始是为空的),当把旧串 里的全部字母拿掉,这个时候就形 ...

  3. sharepoint具体错误提示

    sharepoint页面发生错误时,默认不会显示具体错误信息,只显示“未知错误”提示.需要修改配置站点的webconfig文件,才能显示出具体错误提示.具体方法如下: 将safeMode中的CallS ...

  4. C#、ASP.NET、WinForm - 实现邮件发送的功能

    转载自:http://www.cnblogs.com/mingmingruyuedlut/archive/2011/10/14/2212255.html 发送邮件所用的核心知识点 微软封装好的Mail ...

  5. linux命令:使用man, 导出man

    要查一个命令怎么使用,使用"man 命令", eg: man find, man ls; "info 命令"貌似也可以看, info find, info ls ...

  6. Eclipse用法和技巧二:自动生成Main方法1

    刚开始编写java小程序,基本都要用到main方法.后期开发大一点的程序,也可以用main方法进行单元测试.总是编写main方法,感觉太无聊了,幸好Eclipse可以帮我们自动生成main方法.见图: ...

  7. Windows通过远程桌面访问Ubuntu

    关于Windows通过远程桌面访问Ubuntu 问题及目标 Window环境通过远程桌面访问Ubuntu Ubuntu机器端   1.  安装所需软件包   sudoapt-get install x ...

  8. 论文阅读笔记 - YARN : Architecture of Next Generation Apache Hadoop MapReduceFramework

    作者:刘旭晖 Raymond 转载请注明出处 Email:colorant at 163.com BLOG:http://blog.csdn.net/colorant/ 更多论文阅读笔记 http:/ ...

  9. 简易的sniffer程序

    真的非常简易,这个程序不过抓一些发送到本机的数据包,然后显示出来它们的一些信息罢了.      程序很easy!       #include <WinSock2.h> #include ...

  10. JS - 提示是否删除

    1. OnClientClick="return confirm('确定要删除吗?') 2.自定义函数: 函数: <script type ="text/javascript ...