ITPub博客

首页 > Linux操作系统 > Linux操作系统 > The SELECT ... FOR UPDATE

The SELECT ... FOR UPDATE

原创 Linux操作系统 作者:280511772 时间:2009-01-04 21:02:02 0 删除 编辑
The SELECT ... FOR UPDATE statement identifies the rows that will be updated or deleted, then locks each row in the result set. This is useful when you want to base an update on the existing values in a row. In that case, you must make sure the row is not changed by another user before the update.

The optional keyword NOWAIT tells Oracle not to wait if requested rows have been locked by another user. Control is immediately returned to your program so that it can do other work before trying again to acquire the lock. If you omit the keyword NOWAIT, Oracle waits until the rows are available.

All rows are locked when you open the cursor, not as they are fetched. The rows are unlocked when you commit or roll back the transaction. So, you cannot fetch from a FOR UPDATE cursor after a commit.

When querying multiple tables, you can use the FOR UPDATE clause to confine row locking to particular tables. Rows in a table are locked only if the FOR UPDATE OF clause refers to a column in that table.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13545951/viewspace-526565/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-09-19

  • 博文量
    23
  • 访问量
    21781