什么是不可序列化调度?在交易数据库中
谁能解释一下事务数据库中什么是不可序列化的。请举个例子。 r1(x) r2(x)w1(y) c2 c1 这是不可序列化的吗?
Can anyone explain me what is non-serializable in transaction DB. please give me an example. r1(x) r2(x)w1(y) c2 c1 is this non-serializable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
想象一下这个表(在
Oracle
中):现在我们在两个会话中启动两个
READ COMMITTED
事务:并发出以下查询:
然后,然后:
结果将是这样的:
,即两条记录都将具有
value = 2
第一个查询使两条记录都具有
value = 1
,第二个查询看到这些更改并使两条记录都具有value = 2 。
如果我们对
SERIALIZABLE
级别执行相同的操作,结果将是这样的:,即查询将仅交换
值
的可序列化事务将数据库视为除了事务本身所做的更改之外,状态与事务开始时完全相同。
Imagine this table (in
Oracle
):Now we start two
READ COMMITTED
transactions in two sessions:and issue the following queries:
and, then:
The outcome will be this:
, i. e. both records will have
value = 2
The first query made both records to have
value = 1
, the second query saw these changes and made both records to havevalue = 2
.If we did the same with
SERIALIZABLE
level, the outcome would be this:, i. e. the queries will just swap the
value
'sA serializable transaction sees the database in exactly same state it was when the transaction had begun, except for the changes made by the transaction itself.