READ_UNCOMMITTED vs No transactions?

前端 未结 2 1500
醉梦人生
醉梦人生 2020-12-21 17:35

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

Clarification: I\'m

2条回答
  •  感情败类
    2020-12-21 18:14

    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, 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.

    Note also the setTransactionIsolation method:

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

    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 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.

提交回复
热议问题