标签: sql sql-server postgresql
在sql server
begin tran select * from foos with (rowlock, xlock, holdlock) where id =7 ... commit tran
将锁定该行以进行读写,并将保持锁定直至交易结束,
在postgresql中有相同的吗?
答案 0 :(得分:2)
试试这个:
BEGIN tran; SELECT * FROM foos FOR UPDATE; ... COMMIT tran;
参考:SELECT ... FOR UPDATE
答案 1 :(得分:0)
查看pg_advisory_lock()