暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle 事务集一致性

askTom 2018-01-19
282

问题描述

您好,我正在阅读 <<数据库概念>>,

我无法清楚地理解 “交易集一致性”,您能向我解释一下吗?你能告诉我一些简单的例子来展示什么是 “事务集一致性” 吗?

谢谢。

链接是https://docs.oracle.com/cd/B28359_01/server.111/b28318/consist.htm#CIHHDFDH;

A useful way to view the read committed and serializable isolation levels in Oracle Database is to consider the following scenario: Assume you have a collection of database tables (or any set of data), a particular sequence of reads of rows in those tables, and the set of transactions committed at any particular time. An operation (a query or a transaction) is transaction set consistent if all its reads return data written by the same set of committed transactions. An operation is not transaction set consistent if some reads reflect the changes of one set of transactions and other reads reflect changes made by other transactions. An operation that is not transaction set consistent in effect sees the database in a state that reflects no single set of committed transactions.


谢谢你


专家解答

它的意思是 “查询结果是否与时间点一致?”

例如,假设您有以下两个事务集:

create table t (
  x int
);

/* Tran 1 */
insert into t values (1);
commit;

/* Tran 2 */
update t set x = 2;
commit;
复制


如果查询或事务在t上的查询返回相同的结果,则该查询或事务是 “设置一致的”,而不管这些事务中的哪一个已经完成。

在Oracle数据库中,所有查询都设置为一致-结果在启动时是固定的。

但是在默认模式下,read committed,事务不是。如果运行事务1 (插入),则在单独的会话中运行:

select * from t;

  X
  1

-- run tran 2 in the other session

select * from t;

  X
  2
复制


结果是不同的。因此,每个查询都会看到一组不同的事务的结果。因此,它们不是 “设置一致的”。

但是如果你在可序列化模式下重复测试,它们是:

alter session set isolation_level = serializable;

select * from t;

  X
  1

-- run tran 2 in the other session

select * from t;

  X
  1
复制


因此,结果与同一组事务一致; 只是tran 1。

您可以从Tom阅读更多关于一致性和隔离级别的信息:

http://www.oracle.com/technetwork/testcontent/o65asktom-082389.html
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论