oracle 中 commit 是如何工作的
我有几个语句,伪代码看起来像这样:
insert into local_table
crease savepoint sp1
insert into remote_db //using db_link
update local_table2
delete from local_table
commit
现在我对 insert into remote_db
语句有点困惑。正在应用的提交是否有可能对 local_db
和 remote_db
产生不同的影响?
问题陈述有点复杂。将数据从 local_db
复制到 remote_db
的脚本正在生成重复项。经过调查后,这是唯一看起来可疑的地方,但我不确定。如果有人能够阐明 Oracle 的 COMMIT ,我将非常感激
I have couple of statements, the pseudo code would look something like this:
insert into local_table
crease savepoint sp1
insert into remote_db //using db_link
update local_table2
delete from local_table
commit
Now I'm kinda confused as to the insert into remote_db
statement. Would there be any chance that the commit which is being applied has different affect on local_db
and on remote_db
?
The problem statement is kind of complex. The script which copies data from local_db
to remote_db
is producing duplicates. After performing an investigation, that's the only place which looks suspicious but I am not sure. Would really appreciate if someone can shed light on Oracle's COMMIT
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您询问
提交
是否可能导致重复行,不,这是不可能的。鉴于分布式事务发生的方式,该事务有可能根本不会在远程数据库上提交(在这种情况下,它将是远程 DBA 可能需要解决的不确定分布式事务)。但如果事务提交成功,则它将被正确提交。某些行将被提交而其他行则不会,或者提交行为不可能创建在提交之前不存在的重复行。
If you are asking whether the
commit
could potentially cause duplicate rows, no, that's not possible.Given the way that distributed transactions take place, it is possible that that transaction would not be committed at all on the remote database (in which case it would be an in-doubt distributed transaction that the remote DBA would likely need to resolve). But if the transaction is committed successfully, it's going to be committed correctly. It's not possible that some rows would get committed and others wouldn't or that duplicate rows that didn't exist prior to the commit would be created by the act of committing.