如何同步两个数据库模式 Oracle 10G?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2920078/
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
How to synchronize two DataBase Schemas Oracle 10G?
提问by NareshKumar
I am using Oracle 10G.
我正在使用 Oracle 10G。
Let me explain to you. I have one source database named (DB1) and Target Database named (DB2).
让我给你解释一下。我有一个名为 (DB1) 的源数据库和一个名为 (DB2) 的目标数据库。
I have 2 schema's named dbs1 and dbs2 in the source database (DB1).
I have exported both the database schemas in Source Database (DB1) and imported it successfully into the Target Database (DB2).
Now I face a challenge in synchronizing these database schemas every time from Source DB (DB1) to Target DB (DB2).
我在源数据库 (DB1) 中有 2 个名为 dbs1 和 dbs2 的模式。
我已经导出了源数据库 (DB1) 中的两个数据库模式,并将其成功导入到目标数据库 (DB2) 中。
现在,我每次都面临将这些数据库模式从源数据库 (DB1) 同步到目标数据库 (DB2) 的挑战。
Can anyone please help in letting me know how can achieve this synchronization?
谁能帮助我知道如何实现这种同步?
回答by APC
Oracle has its own built-in function to handle this situation: it's called Streams. Find out more. There is also Replication, but that uses materialized views rather than tables in the target database. Find out more.
Oracle 有自己的内置函数来处理这种情况:它称为 Streams。 了解更多。还有复制,但它使用物化视图而不是目标数据库中的表。 了解更多。
Do not look at third party products or attempt to handroll your own implementation until you have considered the functionality you already have.Oracle licenses are expensive: be sure to get your money's worth.
在您考虑已经拥有的功能之前,不要查看第三方产品或尝试手动执行您自己的实现。Oracle 许可证很贵:一定要物有所值。
Setting up data integration between databases is a complex subject, and not one which I would choose to hand to a beginner. However, you will find it easier to get yourself started if you use Oracle's standard functionality. The same applies to asking for help, here or in other forums.
在数据库之间设置数据集成是一个复杂的主题,我不会选择交给初学者。但是,如果您使用 Oracle 的标准功能,您会发现更容易上手。这同样适用于在此处或在其他论坛寻求帮助。
The three key issues you have to decide on are:
您必须决定的三个关键问题是:
synchronicityDo you want the Target DB to be completely up-to-date with the Source database? Or is it sufficient to apply updates asynchronously, perhaps even in batches? At the extreme case, synchronous updates result in distributed transactions, where two-phase commit means changes to data in Source DB must also be applied to Target DB as part of the same transaction.
structural changesIt's easy enough to propagate DML changes from one schema to another, but what about DDL - new columns, new tables, etc.
directionalityWill all the changes always go from Source DB to Target DB? Are there any prospects of data changes be propagated in the other direction? In a related question, can the data in Target DB be changed independently of changes in the Source DB? Or is the Target DB read only?
同步性您希望目标数据库与源数据库完全同步吗?或者异步应用更新就足够了,甚至是批量更新?在极端情况下,同步更新会导致分布式事务,其中两阶段提交意味着对源数据库中数据的更改也必须作为同一事务的一部分应用于目标数据库。
结构更改将 DML 更改从一种模式传播到另一种模式很容易,但是 DDL 呢 - 新列、新表等。
方向性所有的变化是否总是从源数据库到目标数据库?是否有任何数据更改向另一个方向传播的前景?在相关问题中,目标数据库中的数据是否可以独立于源数据库中的更改而更改?或者目标数据库是只读的?
EDIT
编辑
The deprecated IMP/EXP utilities and the more modern DataPump functionality are intended for one-off operations. That is, importing structure and data into an empty schema, or importing data into empty objects. They are not suitable for use in a rolling synchronization operation, one where we have to be apply incremental changes. The appropriate tools for that task are the ones I have already listed: Streams or Replication.
已弃用的 IMP/EXP 实用程序和更现代的 DataPump 功能旨在用于一次性操作。即,将结构和数据导入空模式,或将数据导入空对象。它们不适合在滚动同步操作中使用,在这种操作中我们必须应用增量更改。适合该任务的工具是我已经列出的工具:Streams 或 Replication。
EDIT 2
编辑 2
"Can you please give an example for the same. I would be very thanful to you."
“你能不能举个例子。我会非常感谢你。”
Examples of both Replication andStreams? That would take a chunk of time, and to be quite frank I doubt you can afford my hourly rate. What I can do is point you to some handy resources on Das Interwebs. Martin Zahn has written a Replication Survival Guidewhich is pretty good. Tim Hall has an introduction to Streamson his Oracle-Base site; that's for 9i but it remains a decent primer. Neither of these is a substitute for the documentation, but they will help you get a handle on the different technologies.
复制和流的例子?这将花费大量时间,坦率地说,我怀疑您能否负担得起我的小时费率。我能做的就是向您指出 Das Interwebs 上的一些方便资源。Martin Zahn 写了一本很不错的复制生存指南。Tim Hall在他的 Oracle-Base 站点上介绍了 Streams;那是针对 9i 的,但它仍然是一本不错的入门书。这些都不能替代文档,但它们将帮助您掌握不同的技术。
You describe yourself as "new and very naive to Oracle DB". So you must understand that this is no trivial task. Unfortunately you can't just cut'n'paste some example code and expect it to work. You have a great deal of planning, designing and configuration ahead of you. Start by answering the questions I listed above. You need to know exactly where you are trying to reach before you make any decisions on how to get there.
您将自己描述为“对 Oracle DB 非常陌生且非常天真”。所以你必须明白,这不是一项微不足道的任务。不幸的是,您不能只是剪切和粘贴一些示例代码并期望它能够工作。您需要进行大量的规划、设计和配置工作。首先回答我上面列出的问题。在就如何到达那里做出任何决定之前,您需要确切地知道您要到达的地方。