from my perspective, you can use row exclusive lock to accomplish the taskfist,select * from table for update, then the other sessions will merely have read only privilege on the rows that you selectedby doing this way, you can avoid other user updating the data that you need to ensure the data consitency

解决方案 »

  1.   

    select ... from .. for update
      

  2.   

    select * from table for update 是row share lock吧
    row share lock和row exclusive lock好像能不能阻止别的trasaction执行insert。
    通过table lock应该是可以把整个表锁住,但有问题:
    1 我要读多个表,不能保证锁住的表是在同一时刻的
    2 锁表效率低,多的session不能写数据
    我的目的是读多个表在某一时刻的快照,应该并不需要锁,最好能用isolation level解决