• 首页
  • 在线考试
  • 在线课程
  • 论坛交流
  • 付款方式
  • 更多
    • 考试报名
    • 成绩查询
    • QQ群联盟
    • 试题库
    • 帮助中心
    • 资料下载
设java认证为主页 | 注册 | 登录

  • 财会类
    • 财会类
    • 会计从业证
    • 初级职称
    • 中级职称
    • 高级职称
    • 注册会计师
    • 经济师
    • 银行从业
    • 更多>>
  • 建筑类
    • 建筑类
    • 一级建造师
    • 二级建造师
    • 造价工程师
    • 监理工程师
    • 结构工程师
    • 房产估价师
    • 建筑师
    • 更多>>
  • 职业资格
    • 职业资格
    • 公务员
    • 证券从业
    • 教师资格
    • 秘书资格
    • 司法考试
    • 导游资格
    • 更多>>
  • 公务员
    • 公务员
    • 公开选拔
    • 招警
    • 行政能力
    • 申论
    • 面试
    • 真题大全
    • 经验交流
    • 更多>>
  • 外贸类
    • 外贸类
    • 报关员考试
    • 外销员考试
    • 报检员
    • 货代考试
    • 物流师考试
    • 单证员考试
    • 更多>>
  • 医药类
    • 医药类
    • 执业医师
    • 中医医师
    • 执业护士
    • 更多>>
  • 外语类
    • 外语类
    • CET4
    • CET6
    • 托福
    • 雅思
    • 职称英语
    • 小语种
    • 在线听力
    • 更多>>
  • 学历考试
    • 学历考试
    • 高考
    • 成人高考
    • 考研
    • 自考
    • 考博
    • 在职硕士
    • 更多>>
  • 计算机类
    • 计算机类
    • 计算机二级
    • 一三四级
    • 软件水平
    • 微软认证
    • 思科认证
    • 更多>>
  • 全部分类
    • 全部分类
    • 所有考试
    • 更多>>

 首页 >> IT认证 >> Java认证
  • 考试大品牌推荐:
  • 视频课程
  • 模拟考试系统
JAVA首页
网校培训 | 考试动态 | 报考指南 | 公共基础知识指导 | 专业语言部分指导 | 历年真题 | 练习与模拟题 | 综合辅导 | 技巧心得 | 论坛交流
您现在的位置:考试大 >> Java认证考试资格考试 >> 专业语言 >> 文章内容
 
站内搜索:
oracle事务隔离级别,用jdbc体验
来源:考试大   2007/5/17  【考试大:中国教育考试第一门户】   模拟考场   视频课程
Oracle 支持的 2 种事务隔离级别 Read committed , Serializable

用 JDBC 进行了测试和学习,根据自己的理解写点心得,这里全部是我个人的看法和理解,如果错误之处请大家告诉我,以便误导他人同时也会使我学习到更多的东西。

 

 

所需数据准备如下:

item

item_value

action_time

id

aaa

LOOCKY

06-12-2006 15:23:54

1

tsindex

users

06-12-2006 15:23:54

2

tstemp

temp

06-12-2006 15:23:54

3

 

来自 oracle 官方网站的 Read committed , Serializable 的解释

 

Isolation Level

Description

Read committed

This is the default transaction isolation level. Each query executed by a transaction sees only data that was committed before the query (not the transaction) began. An Oracle query never reads dirty (uncommitted) data.

Because Oracle does not prevent other transactions from modifying the data read by a query, that data can be changed by other transactions between two executions of the query. Thus, a transaction that runs a given query twice can experience both nonrepeatable read and phantoms.

Serializable

Serializable transactions see only those changes that were committed at the time the transaction began, plus those changes made by the transaction itself through INSERT , UPDATE , and DELETE statements. Serializable transactions do not experience nonrepeatable reads or phantoms.

 

2 者的区别也是来自官方网站

summarizes key differences between read committed and serializable transactions in Oracle.

Table 13-2 Read Committed and Serializable Transactions

 

Read Committed

Serializable

Dirty write

Not possible

Not possible

Dirty read

Not possible

Not possible

Nonrepeatable read

Possible

Not possible

Phantoms

Possible

Not possible

 

 

上面的 2 个表来自 http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14220/consist.htm

都可以随时查询

 

 

Isolation Level

Description

Read committed

This is the default transaction isolation level. Each query executed by a transaction sees only data that was committed before the query (not the transaction) began. An Oracle query never reads dirty (uncommitted) data.

Because Oracle does not prevent other transactions from modifying the data read by a query, that data can be changed by other transactions between two executions of the query. Thus, a transaction that runs a given query twice can experience both nonrepeatable read and phantoms.

默认的隔离级别设置。事务中的查询只能看到在此查询之前( 而非事务开始之前 )提交的数据。

由于 oracle 不会因为查询数据而阻止另外一个事务修改数据,因此数据可以在一个事务中的 2 次查询中,查到不同的结果。因此

可能出现 nonrepeatable read and phantoms 的情况

 

 

 

 

 

Serializable

Serializable transactions see only those changes that were committed at the time the transaction began, plus those changes made by the transaction itself through INSERT , UPDATE , and DELETE statements. Serializable transactions do not experience nonrepeatable reads or phantoms.

 

根绝我的理解解释一下:

serializable transactions 在事务执行: 2 次同一条数据查询的时候(就是两次执行查询,就是说执行完第一个 .executeQuery ,然后执行第二个 .executeQuery ),如果在第一个 .executeQuery 开始执行而另外一个事务已经开始修改数据,并且已经提交,那么两次读取的数据是另外一个事务修改前的数据。

如果在第一个 .executeQuery 之前,另外一个事务修改了数据,那么两次读取的数据是另外一个事务修改后的数据。

这恰恰反映了, repeatable read ,两次结果一致

这与 Read committed 完全不同,

要是 Read committed ,第一个 .executeQuery 未执行完第二事务,而在第二个 .executeQuery 前第二个事务执行完毕,那么第一个 .executeQuery 得到的是初始数据,而第二个 .executeQuery 得到的是修改后的数据

恰恰说明了 nonrepeatable read ,两次结果不一致的情况

来源:考试大-Java认证

责编:wyl  纠错

[1] [2] [3] 下一页

【收藏此页】【大 中 小】【打印】【回到顶部】
上一篇文章:Java中的文件与磁盘操作技术详细解析
下一篇文章:用Jsp来实现文件下载功能的几种方式
文章搜索:
 相关文章
·JSF开发问题和解决
·Spring工作原理探秘
·Ubuntu下Java环境的搭建
·Java与.NET的WebServices相互调用
·用TableModelFree框架简化Swing开发
·Java虚拟机概念及体系结构详述
   
资讯快报
考试动态
行业新闻
备考辅导
模拟试题
历年真题
技巧心得
热门课程培训
更多..
论坛热帖
更多..