SQL SERVER里的锁机制

表锁

1:TABLOCK(表锁) 保证其他进程只能读取而不能修改数据。

select * from t_country  with (TABLOCK)

2:TABLOCKX(排它表锁) 防止其他进程读取或修改表中的数据。

select * from t_country  with (TABLOCKX)

行锁

行级锁即可保证数据的一致性,又能提高数据操作的并发性。

select * from tableName  with (rowlock) where id = 'X';

猜你喜欢

转载自www.cnblogs.com/liuyj-dev/p/10007024.html