简体   繁体   English

SELECT的事务隔离级别

[英]Transaction isolation level for SELECTs

Given a transaction running on a Relational Database, firing a series of SELECTS. 给定在关系数据库上运行的事务,触发一系列SELECTS。

I am supposing that if in the middle of this transaction, any other transaction commits some UPDATE or INSERT against the database, this new data is VISIBLE for the rest of the remaining selects in the former transaction. 我假设如果在此事务的中间,任何其他事务对数据库提交一些UPDATE或INSERT,则此新数据对于前一事务中的其余剩余选择是可见的。 Is this assumption correct? 这个假设是否正确?

I mean, I am supposing that the transaction is not isolated for reading ( it always reads the last state of the Database even if it changes in the meanwhile ), but only for the writings, is it? 我的意思是,我假设事务没有被隔离用于读取( 它总是读取数据库的最后状态,即使它同时发生了变化 ),但仅针对着作,是吗?

If this depends on the the transactional policy of each RDBMS, what is the policy of Oracle? 如果这取决于每个RDBMS的事务策略,那么Oracle的策略是什么?

Your assumption is correct, at least for Oracle. 您的假设是正确的,至少对于Oracle而言。

Oracle guarantees the consistency of a read performed at a given moment. Oracle保证在给定时刻执行的读取的一致性。 Once the read is initiated, it doesn't matter if other transactions change the data being selected - Oracle guarantees the data is what was in the database at the start of the read. 一旦启动读取,其他事务是否会更改所选数据并不重要 - Oracle保证数据是读取开始时数据库中的数据。 If it can't honor that guarantee, you get an "ORA-01555 snapshot too old" error. 如果它无法兑现该保证,则会出现“ORA-01555快照太旧”错误。 However, subsequent selects may not get the same answer. 但是,后续选择可能无法得到相同的答案。

In order to provide read isolation/repeatable reads, you have to give up some concurrency, because you have to lock the table against updates. 为了提供读取隔离/可重复读取,您必须放弃一些并发性,因为您必须锁定表以防止更新。 Oracle chose to be highly concurrent - readers don't block. Oracle选择高度并发 - 读者不会阻止。

If you're just looking for data at a given point in time, Oracle does provide flashback queries. 如果您只是在给定时间点查找数据,Oracle确实提供了闪回查询。

Copy&Pasting the answer given as comment to the question: 复制并粘贴作为对问题的评论给出的答案:

The default isolation level in Oracle is "read committed" (you "see" changes committed by other transactions, even if they were committed after your transaction started). Oracle中的默认隔离级别是“已提交读取”(您“看到”其他事务所提交的更改,即使它们是在事务启动后提交的)。 Oracle also allows you to set the isolation level to "serializable" (you only "see" changes that had been committed by other transactions at the time your transaction started) or "read only" (like "serializable", except that it does not allow to INSERT, UPDATE, or DELETE). Oracle还允许您将隔离级别设置为“可序列化”(您只“看到”在事务开始时由其他事务提交的更改)或“只读”(如“可序列化”,但它不是允许INSERT,UPDATE或DELETE)。 For all the details, see link . 有关所有详细信息,请参阅链接

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

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