如何同步两个Oracle数据库? [英] How do I synchronize two Oracle Databases?

查看:226
本文介绍了如何同步两个Oracle数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个需要将本地数据库与远程数据库同步的项目。本地数据库中所做的更改必须反映到远程数据库。这必须同步进行。我有应用程序对在java / jpa写的本地数据库执行CRUD操作。同步应该从java代码触发。
我想到数据库的每个表上的触发器,它将维护本地数据库中的更改。但我怀疑它的安全或不。
googling之后,我发现oracle lite数据库最适合同步两个数据库,但我需要快速开始。
操作系统我使用的是Windows XP。数据库大小约为2gb。

I want to create a project in which it is required to synchronize local database with remote database. Changes made in local database must be reflected to remote database. This must be done synchronously. I have application which does CRUD operations on local database written in java/jpa. Synchronization should be triggered from java code. I thought of triggers on each table of database which will maintain changes in local database. But I doubt its secure or not. After googling I found out that oracle lite database is best for synchronizing two databases, but I need to get started quickly. Operating system I am using is Windows Xp. Database size is around 2gb.

我创建了一个线程来实现同样的事情在java,但从suggetion我重新启动同一个线程在数据库上下文。

I did created thread for achieving same thing in java but from suggetion I restarted same thread in the database context.

推荐答案

首先,我建议您重新考虑您的设计。要重新创建数据,最简单的方法是通过此SO中建议的视图。您可以在两个数据库之间创建一个DATABASE LINK,并在远程站点上创建查询本地数据库的视图。这将是实时同步的最简单的方法(更少的代码,更少的维护)。

First of all I'd suggest you reconsider your design. The simplest way to repicate your data is through views as suggested in this SO. You could create a DATABASE LINK between your two DBs and create views at the remote site that would query the local database. This would be the simplest way to have Real-Time synchronization (less code, less maintenance).

如果你真的想同步复制你的数据, a href =http://download.oracle.com/docs/cd/B19306_01/server.102/b14226/toc.htm =noreferrer>复制指南。你可以去物化视图。您需要定义实体化视图日志在您的主站点上的表上。在远程站点,您将创建 ON COMMIT REFRESH实现视图

If you really want to replicate your data synchronously, you should read the Replication Guide. You could go with materialized views. You will need to define materialized view logs on your tables at your master site. At the remote site you will create ON COMMIT REFRESH materialized views.

这篇关于如何同步两个Oracle数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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