本文介绍了Oracle等效于ROWLOCK,UPDLOCK,READPAST查询提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In SQL Server I used the following hints inside queries:

  • 行锁(行级锁定)
  • updlock(防止脏读)
  • readpast(不要阻塞等待行锁,请转到第一行未锁定的行)

例如

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

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

Are there equivalent in-query hints for Oracle?

推荐答案

ROWLOCK等效的是FOR UPDATE子句

select *
from emp
for update;

自11g起,Oracle已记录了SKIP LOCKED语法,该语法与READPAST等效:

Since 11g Oracle has documented the SKIP LOCKED syntax which is the equivalent of 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,

没有等效的UPDLOCK锁,因为Oracle完全禁止进行脏读.了解更多.

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

这篇关于Oracle等效于ROWLOCK,UPDLOCK,READPAST查询提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 08:24