简体   繁体   English

跟踪Oracle中数据更改的最佳方法

[英]the best way to track data changes in oracle

as the title i am talking about, what's the best way to track data changes in oracle? 作为我正在谈论的标题,跟踪oracle中数据更改的最佳方法是什么? i just want to know which row being updated/deleted/inserted? 我只想知道要更新/删除/插入的那一行?

at first i think about the trigger, but i need to write more triggers on each table and then record down the rowid which effected into my change table, it's not good, then i search in Google, learn new concepts about materialized view log and change data capture, 起初,我想到了触发器,但是我需要在每个表上写更多的触发器,然后记下影响到变更表的rowid,这不好,然后我在Google中搜索,学习有关物化视图日志和变更的新概念数据抓取,

materialized view log is good for me that i can compare it to original table then i can get the different records, even the different of the fields, i think the way is the same with i create/copy new table from original (but i don't know what's different?); 物化视图日志对我很有好处,我可以将其与原始表进行比较,然后我可以获得不同的记录,甚至是不同的字段,我认为从原始创建/复制新表的方式也是相同的(但是我不不知道有什么不同?);

change data capture component is complicate for me :), so i don't want to waste my time to research it. 更改数据捕获组件对我来说很复杂:),所以我不想浪费时间来研究它。

anybody has the experience the best way to track data changes in oracle? 任何人都具有跟踪oracle中数据更改的最佳方法的经验吗?

You'll want to have a look at the AUDIT statement. 您将需要查看AUDIT语句。 It gathers all auditing records in the SYS.AUD$ table. 它收集SYS.AUD $表中的所有审核记录。

Example: 例:

AUDIT insert, update, delete ON t BY ACCESS

Regards, 问候,
Rob. 抢。

You might want to take a look at Golden Gate. 您可能想看看金门大桥。 This makes capturing changes a snap, at a price but with good performance and quick setup. 这使捕获更改变得很容易,但价格不菲,但性能良好且设置迅速。

If performance is no issue, triggers and audit could be a valid solution. 如果性能没有问题,则触发器和审计可能是有效的解决方案。 If performance is an issue and Golden Gate is considered too expensive, you could also use Logminer or Change Data Capture. 如果性能是一个问题,并且认为Golden Gate太昂贵,您也可以使用Logminer或Change Data Capture。 Given this choice, my preference would go for CDC. 有了这个选择,我更喜欢CDC。 As you see, there are quite a few options, near realtime and offline. 如您所见,有很多选项,接近实时和离线。

Coding a solution by hand also has a price, Golden Gate is worth investigating. 手动编写解决方案也需要付出代价,金门大桥值得研究。

Oracle does this for you via redo logs, it depends on what you're trying to do with this info. Oracle通过重做日志为您完成此操作,这取决于您要使用此信息做什么。 I'm assuming your need is replication (track changes on source instance and propagate to 1 or more target instances). 我假设您需要复制(跟踪源实例上的更改并将其传播到1个或多个目标实例)。

If thats the case, you may consider Oracle streams (other options such as Advanced Replication, but you'll need to consider your needs): 如果是这样,您可以考虑使用Oracle流(其他选项,例如“高级复制”,但是您需要考虑自己的需求):

From Oracle: 从Oracle:

When you use Streams, replication of a DML or DDL change typically includes three steps: 使用Streams时,DML或DDL更改的复制通常包括三个步骤:

A capture process or an application creates one or more logical change records (LCRs) and enqueues them into a queue. 捕获过程或应用程序将创建一个或多个逻辑变更记录(LCR),并将它们排入队列。 An LCR is a message with a specific format that describes a database change. LCR是具有特定格式的消息,用于描述数据库更改。 A capture process reformats changes captured from the redo log into LCRs, and applications can construct LCRs. 捕获过程会将从重做日志捕获的更改重新格式化为LCR,应用程序可以构造LCR。 If the change was a data manipulation language (DML) operation, then each LCR encapsulates a row change resulting from the DML operation to a shared table at the source database. 如果更改是数据操作语言(DML)操作,则每个LCR会将DML操作导致的行更改封装到源数据库的共享表中。 If the change was a data definition language (DDL) operation, then an LCR encapsulates the DDL change that was made to a shared database object at a source database. 如果更改是数据定义语言(DDL)操作,则LCR会封装对源数据库中的共享数据库对象进行的DDL更改。

A propagation propagates the staged LCR to another queue, which usually resides in a database that is separate from the database where the LCR was captured. 传播会将分段的LCR传播到另一个队列,该队列通常位于与捕获LCR的数据库不同的数据库中。 An LCR can be propagated to a number of queues before it arrives at a destination database. LCR在到达目标数据库之前可以传播到多个队列。

At a destination database, an apply process consumes the change by applying the LCR to the shared database object. 在目标数据库上,应用过程通过将LCR应用于共享数据库对象来消耗更改。 An apply process can dequeue the LCR and apply it directly, or an apply process can dequeue the LCR and send it to an apply handler. Apply进程可以使LCR出队并直接应用它,或者Apply进程可以使LCR出队并发送给Apply处理程序。 In a Streams replication environment, an apply handler performs customized processing of the LCR and then applies the LCR to the shared database object. 在Streams复制环境中,应用处理程序执行LCR的自定义处理,然后将LCR应用于共享数据库对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM