Oracle删除跳过锁定
Oracle delete skip locked
oracle 是否允许在某些条件下从 table 中删除行并跳过锁定一次
DELETE from t
WHERE t.id IN (SELECT id
FROM t
WHERE id in ('1','2')
FOR UPDATE SKIP LOCKED )
例如 id 2 被其他会话锁定,删除脚本应该跳过该行
上面的查询总是失败并出现错误
ORA-00907: missing right parenthesis
版本:Oracle 11G XE
FOR UPDATE
子句仅对顶级SQL语句有效,对子查询无效。
http://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_10002.htm#SQLRF55370
根据 Jeffrey 的回答,我认为该条款旨在用于 PL/SQL 块。所以你可以试试这个,例如:
begin
for r in (select rowid as rid from t for update skip locked)
loop
delete from t where rowid = r.rid;
end loop;
end;
/
oracle 是否允许在某些条件下从 table 中删除行并跳过锁定一次
DELETE from t
WHERE t.id IN (SELECT id
FROM t
WHERE id in ('1','2')
FOR UPDATE SKIP LOCKED )
例如 id 2 被其他会话锁定,删除脚本应该跳过该行
上面的查询总是失败并出现错误
ORA-00907: missing right parenthesis
版本:Oracle 11G XE
FOR UPDATE
子句仅对顶级SQL语句有效,对子查询无效。
http://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_10002.htm#SQLRF55370
根据 Jeffrey 的回答,我认为该条款旨在用于 PL/SQL 块。所以你可以试试这个,例如:
begin
for r in (select rowid as rid from t for update skip locked)
loop
delete from t where rowid = r.rid;
end loop;
end;
/