關於Oracle LOGMNR找不到dml操作及補充日誌相關

spectre2發表於2013-09-09

在Oracle10g中,使用LOGMNR找不到剛剛執行的DML操作,參考METALINK的Bug No. 3877515。

在沒有設定SUPPLEMENTAL LOG DATA時,10g使用記憶體UNDO技術IMU(IN-MEMORY UNDO),而這種技術是LOGMNR所不支援的。因此通過LOGMNR分析10g的記錄是得不到結果的。而9i則沒有這種情況。

不過值得欣慰的是,Oracle11g中,即使不設定SUPPLEMENTAL LOG DATA,也可以通過LOGMNR獲取DML,Oracle的LOGMNR預設狀態又恢復到了9I的情況:

在METALINK的Doc ID: Note:291574.1中,提供了詳細的解決方法:

如果希望LOGMNR可以得到記錄,應該設定SUPPLEMENTAL LOG DATA PRIMARY KEY和UNIQUE INDEX,這樣Oracle才能確保LOGMNR可以獲取SQL語句:

SQL> SELECT SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI FROM V$DATABASE;

SUP SUP
--- ---
NO NO

SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY, UNIQUE INDEX) COLUMNS;

資料庫已更改。

SQL> SELECT SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI FROM V$DATABASE;

SUP SUP
--- ---
YES YES


如果不想設定SUPPLEMENTAL LOG DATA PRIMARY KEY和UNIQUE INDEX,可以選擇設定最小補充日誌:


You must enable supplemental logging prior to generating log files that will be analyzed by LogMiner.
When you enable supplemental logging, additional information is recorded in the redo stream that is needed to make the information in the redo log files useful to you. Therefore, at the very least, you must enable minimal supplemental logging, as the following SQL statement shows:

ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

To determine whether supplemental logging is enabled, query the V$DATABASE view, as the following SQL statement shows:

SELECT SUPPLEMENTAL_LOG_DATA_MIN FROM V$DATABASE;

If the query returns a value of YES or IMPLICIT, minimal supplemental logging is enabled. See Supplemental Logging for complete information about supplemental logging.

 

取消補充日誌
   alter database drop supplemental log data (primary key) columns;
   alter database drop supplemental log data (unique) columns;
   alter database drop supplemental log data;


 

關於補充日誌的詳細說明,可以參考http://www.itpub.net/thread-1790897-1-1.html

本文參考:

http://www.itpub.net/thread-980002-1-1.html

http://yangtingkun.itpub.net/post/468/464865

http://yangtingkun.itpub.net/post/468/464900

http://www.itpub.net/thread-1790897-1-1.html

 

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/14184018/viewspace-772385/,如需轉載,請註明出處,否則將追究法律責任。

相關文章