以前一直以为for update of table.col可以锁定到字段,今天才发现,还是只能锁定到行。那和 for update还有什么区别呢?必须连接查询多个表的时候of才有用吗

解决方案 »

  1.   

    1select * from TTable1 for update锁定表的所有行,只能读不能写2select * from TTable1 where pkid = 1 for update只锁定pkid=1的行 3select  * from Table1 a join Table2 b on a.pkid=b.pkid for update锁定两个表的所有记录4select  * from Table1 a join Table2 b on a.pkid=b.pkid  where  a.pkid = 10 for update锁定两个表的中满足条件的行5.select  * from Table1 a join Table2 b on a.pkid=b.pkid  where  a.pkid = 10 for update of a.pkid只锁定Table1中满足条件的行刚搜索的
      

  2.   

    1楼太快了,一点不给别人机会,呵
    for update 是把所有的表都锁点
    for update of 根据of 后表的条件锁定相对应的表
      

  3.   

    原来oracle里没有对于字段级别的锁,还以为后边加of是锁定某个字段不能更新呢?现在明白了,谢谢大家
      

  4.   

    for update of 说得不对,根据oracle文档,它是用来锁字段的。http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10826/pco03dbc.htm#i4233RestrictionsYou cannot use FOR UPDATE with multiple tables, but you must use FOR UPDATE OF to identify a column in the table that you want locked. Row locks obtained by a FOR UPDATE statement are cleared by a COMMIT, which explains why the cursor is closed for you. If you try to fetch from a FOR UPDATE cursor after a commit, Oracle generates a Fetch out of Sequence error.
      

  5.   

    for update of 说得不对,根据oracle文档,它是用来锁字段的。--by theoffspring====================================
    到底是锁行还是锁字段呢??