开发者

SQL Server NOLOCK keyword

When a SQL client issues the following command:

select * into tbl2
FROM tbl1 开发者_开发技巧(nolock)
WHERE DateCreated < '2009/01/01'

does it mean that the command won't lock tbl1 or it won't be blocked by other uncommitted transactions made to tbl1?

Update:

[NOLOCK]: Specifies that dirty reads are allowed. No shared locks are issued to prevent other transactions from modifying data read by the current transaction, and exclusive locks set by other transactions do not block the current transaction from reading the locked data. REF: MSDN


It means the first; you're not taking out any locks and therefore the second; you wont be blocked by other open transactions. See MSDN docs on table hints.

Here's a link to the MSDN docs on transaction isolation levels - might be useful if you're considering using NOLOCK. NOLOCK puts the SQL statement at isolation level read uncommitted. If you have a multi-statement transaction you may be able to set the isolation level at a lower level for the majority of the transaction and raise it where needed, rather than lowering it just on one or more statements in the transaction.


Both. And it will also read uncommitted data from other [uncommitted] transactions (if any).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜