如何跟踪oracle数据库中特定表上的所有DML活动。我需要监视它。
使用Oracle审计或细粒度审计。最基本的配置:
-
设置audit_track初始化参数并重新启动数据库:
SQL> ALTER SYSTEM SET audit_trail=db SCOPE=SPFILE; System altered. SQL> SHUTDOWN Database closed. Database dismounted. ORACLE instance shut down. SQL> STARTUP ORACLE instance started. Total System Global Area 289406976 bytes Fixed Size 1248600 bytes Variable Size 71303848 bytes Database Buffers 213909504 bytes Redo Buffers 2945024 bytes Database mounted. Database opened. SQL>
-
在您的表上配置审核:
audit insert, update, delete on [owner].[table_name] by access;
-
使用DBA_AUDIT_TRAIL视图可以查看审核记录。
这两个主题都相当大,需要在这里详细介绍,但您可以在这里开始研究/阅读Oracle 11g:的实际示例
- https://docs.oracle.com/cd/E11882_01/server.112/e10575/tdpsg_auditing.htm#TDPSG50000
- https://oracle-base.com/articles/10g/auditing-10gr2