SQL Server - 脏读优点 &缺点 [英] SQL Server - Dirty Reads Pros & Cons

查看:34
本文介绍了SQL Server - 脏读优点 &缺点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我应该或不应该使用脏读:

Why should I or shouldn't I use dirty reads:

set transaction isolation level read uncommitted

在 SQL Server 中?

in SQL Server?

推荐答案

来自 MSDN:

设置此选项时,可以读取未提交或脏数据;在事务结束之前,数据中的值可以更改,行可以在数据集中出现或消失.

When this option is set, it is possible to read uncommitted or dirty data; values in the data can be changed and rows can appear or disappear in the data set before the end of the transaction.

简单地说,当您使用这种隔离级别,并且您在一个活动表上作为一个事务的一部分执行多个查询时,不能保证在事务的不同部分返回给您的信息将保持不变.您可以在一个事务中两次查询相同的数据并获得不同的结果(这可能发生在不同用户在您的事务中更新相同数据的情况下).这显然会对依赖数据完整性的应用程序部分产生严重影响.

Simply put, when you are using this isolation level, and you are performing multiple queries on an active table as part of one transaction, there is no guarantee that the information returned to you within different parts of the transaction will remain the same. You could query the same data twice within one transaction and get different results (this might happen in the case where a different user was updating the same data in the midst of your transaction). This can obviously have severe ramifications for parts of your application that rely on data integrity.

这篇关于SQL Server - 脏读优点 &缺点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆