READ_UNCOMMITTED与没有交易? [英] READ_UNCOMMITTED vs No transactions?

查看:229
本文介绍了READ_UNCOMMITTED与没有交易?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在READ_UNCOMMITTED隔离模式下执行SQL与执行SQL之间有什么区别?

What's the difference between executing SQL outside of a transaction versus executing it under READ_UNCOMMITTED isolation mode?

澄清:我试图了解 java.sql.Connection.TRANSACTION_NONE之间的差异 java.sql.Connection。 TRANSACTION_READ_UNCOMMITTED

推荐答案

TRANSACTION_NONE 表示连接不支持事务,并且对该连接强加事务语义的任何尝试都将失败。我不能看到这有用,除非你使用一个假数据库,如CSV文件。

TRANSACTION_NONE means that the connection does not support transactions at all, and any attempt to impose transaction semantics on that connection should fail. I can't see this ever being useful, except perhaps in cases where you're using a "fake" database, like CSV files.

另一方面,READ_UNCOMMITTED 意味着连接正在使用事务,并且将能够从其他连接的未提交事务读取数据。

READ_UNCOMMITTED, on the other hand, means that the connection is using transactions, and will be able to read data from other connections' uncommitted transactions. As @Pax said, this should be used with extreme caution.

请注意 setTransactionIsolation 方法:

Note also the setTransactionIsolation method:


请注意,不能使用 Connection.TRANSACTION_NONE ,因为它指定不支持事务。

Note that Connection.TRANSACTION_NONE cannot be used because it specifies that transactions are not supported.

所以你不能强制连接使用 TRANSACTION_NONE - 连接支持事务或它不

So you cannot force a connection to use TRANSACTION_NONE - the connection either supports transactions or it doesn't, and if it doesn't you can't mess with this method.

READ_UNCOMMITTED 仍然意味着你在交易中。您仍然会得到原子写入,并且其他事务仍然与您的写入隔离。然而,你的交易不是孤立于其他人的。 TRANSACTION_NONE 是一个免费的所有 - 没有人从任何隔离。

READ_UNCOMMITTED still means you're in a transaction. You still get atomic writes, and other transactions are still isolated from your writes. However, your transaction is not isolated from other peoples'. TRANSACTION_NONE is a free for all - no one gets isolation from anything.

这篇关于READ_UNCOMMITTED与没有交易?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆