sql server中没有锁意味着什么 [英] No Lock in sql server means what
本文介绍了sql server中没有锁意味着什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在SQL Server中(Nolock)的含义是什么,请举一个例子来解释吗?
What is the meaning of the (Nolock) in sql server and pls explain with an example ?
推荐答案
您已经给出了很多很好的链接,但是我会建议也阅读这篇文章当使用NOLOCK时应该考虑什么使用提示 [ ^ ]
You have given many good links already, but I would suggest also going through this article What should be considered when NOLOCK hint is used[^]
(NOLOCK)
等同于使用READ UNCOMMITED
作为事务隔离级别.因此,您有读取未提交的行并随后回滚的风险,即数据永远不会进入数据库.因此,虽然它可以防止读取因其他操作而陷入僵局.
WITH(NOLOCK)
is the equivalent of usingREAD UNCOMMITED
as a transaction isolation level. So, you stand the risk of reading an uncommitted row that is subsequently rolled back, i.e. data never made it into the database. So, while it can prevent reads being deadlocked by other operations.
SELECT * FROM Employee WITH (READUNCOMMITTED)
这与
一样
this is same as
SELECT * FROM Employee WITH NOLOCK
NOLOCK
和READUNCOMMITED
提示仅允许用于SELECT
语句.如果我们尝试将其用于UPDATE, DELETE or INSERT
,则会收到错误消息.
查看此链接以获取示例.
http://www.mssqltips.com/sqlservertip/2470/understanding-the -sql-server-nolock-hint/ [
The NOLOCK
and READUNCOMMITED
hints are only allowed with SELECT
statements. If we try to use this for an UPDATE, DELETE or INSERT
we will get an error.
Check this link for an example.
http://www.mssqltips.com/sqlservertip/2470/understanding-the-sql-server-nolock-hint/[^]
使用NOLOCK
查询提示时,您告诉存储引擎您要访问数据,无论是否数据是否被另一个进程锁定.
参考链接:- WITH(NOLOCK)到底是什么意思 [ ^ ]
When you use theNOLOCK
query hint you are telling the storage engine that you want to access the data no matter if the data is locked by another process or not.
Reference Link :- What does WITH (NOLOCK) actually mean[^]
这篇关于sql server中没有锁意味着什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文