是否在Oracle上执行了executeBatch()是按顺序完成的? [英] Is the executeBatch() performed on Oracle is done in order?

查看:258
本文介绍了是否在Oracle上执行了executeBatch()是按顺序完成的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这更多是一种理论问题,用于了解Oracle如何处理executeBatch()请求.

This is more of a kind of theory question to understand how the executeBatch() request is handled by Oracle.

考虑到有三个插入语句(PreparedStatement),添加了say语句1,statement2和语句3,以便使用executeBatch()方法并在Oracle上以批处理的方式执行.甚至在语句1完成之前,语句2的执行是否有可能完成?换句话说,通过语句2进行的插入操作能否在通过操作执行的插入操作之前成功完成?

Consider there are three insert statements (PreparedStatement) ,say statement 1, statement2 and statement 3 are added to execute as a batch using executeBatch() method and over Oracle. Will there be a chance that the execution of statement 2 to complete even before statement 1 completes? In other words, can the insert operation by statement 2 succeed before the insert performed by operation ?

提供的自动提交设置为false.

Provided Autocommit is set to false.

预先感谢.

推荐答案

提供的自动提交设置为false

Provided auto-commit set to false

然后,如果您关注插入中间的查询(如您在另一个答案的注释中所提到的),则答案是简单明了的:

Then the answer is straight-forward if you are concerning on querying in the middle of insert (as you have mentioned in comment on another answer):

鉴于在同一连接中,您不能在上一个插入语句完成之前进行查询,这意味着您的查询需要来自其他连接.

Given that in same connection, you cannot do query before your previous insert statement finished, that means your query needs to be from another connection.

在Oracle中,在落实任何插入/更新/删除操作之前,其他连接看不到更改.也就是说,查询将在完成任何插入之前看到快照,直到您提交更改为止.

In Oracle, before any insert/update/delete is committed, the change is not visible to other connection. That means, the query will see the snapshot before any insert is done, until you commit the change.

那么您就不必担心这方面的插入顺序了.

Then you should have no concern about the insert order in such aspect.

这篇关于是否在Oracle上执行了executeBatch()是按顺序完成的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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