一致读的4个作用

一、语句级别读一致

1、提供了语句级的读一致性

2、读不阻塞写

3、写不阻塞读

4、只有同时写同一行数据才互相等待

 

Read consistency, as supported by Oracle, does the following:

1、Guarantees that the set of data seen by a statement is consistent with respect to a single point in time and does not change during statement execution (statement-level read consistence)

2、Ensures that readers of database data do not wait for writers or other readers of the same data

3、Ensures that writers of database data do not wait for readers of the same data

4、Ensures that writers only wait for other writers if they attempt to update identical rows in concurrent transactions

The simplest way to think of Oracle's implementation of read consistency is to imagine each user operating a private copy of the database, hence the multiversion consistency model

 

注:一致性读是oracle区别于其他数据库的重要特点之一,但一般来说,这个一致性读是sql级别的,只针对单个sql有效。
由于业务逻辑需要,我们可能需要在一个事务中的多个sql也能实现读一致性,也就是说,数据源在事务开始时就定下来了,不受其他会话影响。oracle的只读事务可以实现这个功能,它可以在事务级别上实现读一致性。

二、事务级读一致

如在财务结算时,基于特定时间进行几个查询,此时不想看到所有表新修改的数据(即使提交了),

就可以用read only  transactio)

create or replace procedure p_test as
 l_id varchar2(200);
 begin
 set transaction read only;
 select last_name into l_id from test where id=1;
 dbms_output.put_line(l_id);
 dbms_lock.sleep(15);
 select last_name into l_id from test where id=1;
 dbms_output.put_line(l_id);
 end p_test;


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值