2个服务器orcale具有相同的数据库 [英] 2 server orcale have the same database
本文介绍了2个服务器orcale具有相同的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
我有2个orcale服务器:
1- ser1有数据库1
2- ser2有数据库2
* datebase1和daabase2是相同的
我需要使用相同的语句在database1中插入,删除或更新动态地作用于database2中
在此先感谢
hi all
i have 2 orcale server :
1- ser1 have database1
2- ser2 have database2
* datebase1 and daabase2 is the same
i need when i insert , delete or update in database1 dynamically effect in database2 with the same statement
thanks in advance
推荐答案
有几种选择.一种非常简单的方法是在数据库之间创建数据库链接.请参阅: http://download.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_5005.htm [ ^ ]
使用该链接,您可以针对远程服务器执行语句,例如从源服务器中的触发器执行语句.
如果要查找将远程服务器用作备份服务器的解决方案,请查看备用解决方案: ^ ]
[基于评论的添加]
您可以创建两个单独的连接对象,并对两个连接执行必要的语句.
但是,如果您打算在两个服务器上执行完全相同的操作,我相信只有在两个数据库中同时有1个用户和1个用户的情况下,此操作通常才能成功.如果它们是多用户数据库,则另一个应用程序可能会在操作过程中干扰逻辑,并且结果在这些数据库之间可能会有所不同.
另一件事是,如果您对数据库1然后对数据库2执行DML操作,将会发生什么,如果第二个操作没有成功怎么办?根据定义,您还应该回滚第一个操作,但是可以从客户端应用程序可靠地执行此操作.通常在这种情况下使用分布式事务.
There are several options for this. One quite easy way is that you create a database link between the databases. See: http://download.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_5005.htm[^]
Using that link you can execute statements against the remote server for example from a trigger in the source server.
If you''re looking for a solution where the remote server acts as a backup server, then have a look at standby solutions: http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/create_ps.htm[^]
[Addition based on comment]
You can create two separate connection objects and execute necessary statements against both connections.
However, if you plan to do the exact same things on both server I believe that this will only succeed generally if there''s 1 and only 1 user in both databases at the same time. If they are multi-user databases another application may interfere the logic in the middle of an operation and the results may vary among those databases.
Another thing is that what''s going to happen if you execute DML operation against database 1 and then against database 2. What if the second operation isn''t succeeding? By definition you should roll back the first operation also but can you do this reliably from the client application. Typically a distributed transaction is used in these kind of cases.
这篇关于2个服务器orcale具有相同的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文