SQL SERVICE中的锁

 SQL SERVICE中的几个锁

SELECT * FROM dbo.TableName WITH (NOLOCK) --不加任何锁的读,脏读
SELECT * FROM dbo.TableName WITH (HOLDLOCK) --加共享锁,可读单不可更新和删除
SELECT * FROM dbo.TableName WITH (UPDLOCK) --加修改锁
SELECT * FROM dbo.TableName WITH (TABLOCK) --加表锁,
SELECT * FROM dbo.TableName WITH (PAGLOCK) --默认选项页锁
SELECT * FROM dbo.TableName WITH (TABLOCKX) --整个表上置排它锁直至该命令或事务结束,其他事务不能读取表,更新和删除

 

 

你可能感兴趣的:(service)