如果同时从另一个应用程序插入一个应用程序时从Oracle中的序列中获取并发,会发生什么情况? [英] What happens if I get currval from a sequence in Oracle from one application while another application is inserting at the same time?
问题描述
假设我有一个要插入到表中的应用程序(App1),我想从序列中获取当前值
Let's say I have an application (App1) that is inserting into a table and I want to grab the currval from the sequence
-和-
同时,另一个应用程序(App2)插入到我当前正在从App1使用的同一表中.我的currval线程安全吗?我会在App1中获得插入的当前时间,还是有可能从App2中获得插入的当前时间?
At the same time, another application (App2) inserts into the same table I'm currently working with from App1. Is my currval thread-safe? Will I get the currval for my insert in App1 or would it potentially give me the currval for the insert from App2?
推荐答案
currval
定义为返回给您会话的序列的最后一个值.每个会话将具有不同的currval
.获得序列nextval
的其他会话对会话的currval
没有影响.同样,会话的currval
不会告诉您不同的会话如果请求nextval
会得到什么.
currval
is defined to return the last value of the sequence that was given to your session. Every session will have a different currval
. A different session getting the nextval
of a sequence has no impact on your session's currval
. By the same token, your session's currval
tells you nothing about what a different session will get if it asks for the nextval
.
这篇关于如果同时从另一个应用程序插入一个应用程序时从Oracle中的序列中获取并发,会发生什么情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!