Oracle 等价于 ROWLOCK、UPDLOCK、READPAST 查询提示

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3938677/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 21:42:45  来源:igfitidea点击:

Oracle equivalent of ROWLOCK, UPDLOCK, READPAST query hints

sqloraclelocking

提问by Synesso

In SQL Server I used the following hints inside queries:

在 SQL Server 中,我在查询中使用了以下提示:

  • rowlock (row level locking)
  • updlock (prevents dirty reads)
  • readpast (don't block waiting for a rowlock, go to the first unlocked row)
  • rowlock(行级锁定)
  • updlock(防止脏读)
  • readpast(不要阻塞等待行锁,转到第一个未锁定的行)

e.g.

例如

select top 1 data from tablez with (rowlock,updlock,readpast);

Are there equivalent in-query hints for Oracle?

Oracle 是否有等效的查询中提示?

回答by APC

The equivalent of ROWLOCKis the FOR UPDATEclause

相当于ROWLOCKFOR UPDATE从句

select *
from emp
for update;

Since 11g Oracle has documented the SKIP LOCKEDsyntax which is the equivalent of READPAST:

由于 11g Oracle 已经记录SKIP LOCKED了相当于以下内容的语法READPAST

select *
from emp
for update skip locked;

This syntax has worked for ages (it is fundamental to Advanced Queuing) but if it's not in the docs it's not supported,

这种语法已经工作了很长时间(它是高级队列的基础)但如果它不在文档中,则不支持,

There is no equivalent of UPDLOCKlock because Oracle flat out doesn't allow dirty reads. Find out more.

没有等效的UPDLOCK锁,因为 Oracle flat out 不允许脏读。了解更多。