简体   繁体   English

Oracle:哪个Lock是通过Serializable隔离级别获取的

[英]Oracle: Which is Lock is acquired by Serializable isolation level

What I am trying to establish is whether there is any direct relation between Isolation Levels and Locks.我想确定的是隔离级别和锁之间是否有任何直接关系。 So, let's say I started a transaction with a Serializable isolation level then will Oracle by default acquire some type of "Table" lock on all the tables listed in that transaction, if so then what it is?因此,假设我启动了一个具有可序列化隔离级别的事务,然后默认情况下 Oracle 会在该事务中列出的所有表上获取某种类型的“表”锁,如果是这样,那它是什么?

I couldn't find any direct answer to this question, but my own understanding from reading many online docs is that there is no direct relation between Isolation Levels and Locks.我找不到这个问题的任何直接答案,但我自己通过阅读许多在线文档的理解是,隔离级别和锁之间没有直接关系。 Locks will be acquired based on specific SQL statement present in the transaction - and not based on whether the transaction isolation level is Read Committed or Serializable, so if there is a DML then Read Exclusive table lock (RX) will be acquired and if there is a statement like LOCK TABLE table IN EXCLUSIVE MODE;将根据事务中存在的特定 SQL 语句获取锁 - 而不是基于事务隔离级别是 Read Committed 还是 Serializable,因此如果有 DML,则将获取 Read Exclusive 表锁 (RX),如果有像LOCK TABLE table IN EXCLUSIVE MODE; then Exclusive table lock (X) will be acquired.然后将获得排他表锁(X)。

Please note that this question is very specific to Oracle and then very specific on which lock is acquired by Serializable isolation level.请注意,这个问题非常具体到 Oracle,然后非常具体到 Serializable 隔离级别获取哪个锁。 In no way I am looking for answers related to Isolation Levels and Locks available in Oracle, I have read the online docs and understand them.我绝不会在 Oracle 中寻找与隔离级别和锁相关的答案,我已经阅读了在线文档并理解了它们。

I asked same question on Ask Tom as well and graciously Ask Tom has confirmed my understanding - in short, there is no direct relation between Isolation Levels and Locks.我也在 Ask Tom 上问了同样的问题,亲切的 Ask Tom 证实了我的理解——简而言之,隔离级别和锁之间没有直接关系。 Locks will be acquired based on specific SQL statement present in the transaction - and not based on whether the transaction isolation level is Read Committed or Serializable, so if there is a DML then Read Exclusive table lock (RX) will be acquired and if there is a statement like LOCK TABLE table IN EXCLUSIVE MODE;将根据事务中存在的特定 SQL 语句获取锁 - 而不是基于事务隔离级别是 Read Committed 还是 Serializable,因此如果有 DML,则将获取 Read Exclusive 表锁 (RX),如果有像LOCK TABLE table IN EXCLUSIVE MODE; then Exclusive table lock (X) will be acquired.然后将获得排他表锁(X)。

Here is the link of AT answer: https://asktom.oracle.com/pls/apex/asktom.search?tag=oracle-which-lock-is-acquired-by-serializable-isolation-level这是 AT 答案的链接: https://asktom.oracle.com/pls/apex/asktom.search?tag=oracle-which-lock-is-acquired-by-serializable-isolation-level

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM