oracle - 通过 dblink 提交?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9582125/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
oracle - commit over dblink?
提问by toop
If I connect to an oracle database as user smith, and issue the following 3 commands:
如果我以用户 smith 连接到 oracle 数据库,并发出以下 3 个命令:
update smith.tablea
set col_name = 'florence' where col_id = 8;
insert into bob.other_table@mylink
values ('blah',2,'uncle','new');
commit;
Does this mean that the update to the local table (smith.tablea) and the insert to the remote db table (bob.other_table) have both been committed or that just the update to the local table has been committed?
这是否意味着对本地表 (smith.tablea) 的更新和对远程 db 表 (bob.other_table) 的插入都已提交,还是仅提交了对本地表的更新?
Note: that 'mylink' represents a dblink to a remote database.
注意:'mylink' 代表一个到远程数据库的 dblink。
采纳答案by Eggi
In this case the transaction should only work if the remote transaction and your local transaction are successfull.
在这种情况下,只有在远程事务和您的本地事务成功时,事务才能工作。
More information about distributed transactions:
有关分布式事务的更多信息:
http://docs.oracle.com/cd/B19306_01/server.102/b14231/ds_txnman.htm
http://docs.oracle.com/cd/B19306_01/server.102/b14231/ds_txnman.htm
回答by Marcin Wroblewski
From documentation
从文档
The Oracle two-phase commit mechanism is completely transparent to users who issue distributed transactions. In fact, users need not even know the transaction is distributed. A COMMIT statement denoting the end of a transaction automatically triggers the two-phase commit mechanism to commit the transaction. No coding or complex statement syntax is required to include distributed transactions within the body of a database application.
Oracle 两阶段提交机制对发布分布式事务的用户是完全透明的。事实上,用户甚至不需要知道交易是分布式的。表示事务结束的 COMMIT 语句会自动触发两阶段提交机制以提交事务。在数据库应用程序的主体中包含分布式事务不需要编码或复杂的语句语法。
so - yes, if everything goes fine, both operations are commited.
所以 - 是的,如果一切顺利,两个操作都会被提交。