oracle物化檢視日誌系列(三)
oracle物化檢視日誌系列(三)
--報錯原因未新增主鍵列或filtered column到物化檢視日誌的with rowid之中
SQL> create materialized view mv_t refresh fast as select a,count(a) from t_mv group by a;
create materialized view mv_t refresh fast as select a,count(a) from t_mv group by a
ORA-12033: cannot use filter columns from materialized view log on "SCOTT"."T_MV"
SQL> drop materialized view log on t_mv;
Materialized view log dropped
SQL> create materialized view log on t_mv with rowid(a) including new values;
Materialized view log created
SQL> create materialized view mv_t refresh fast as select a,count(a) from t_mv group by a;
Materialized view created
--報錯因為未新增with rowid選項到物化檢視日誌
SQL> create materialized view mv_t refresh fast as select a,count(a) from t_mv group by a;
create materialized view mv_t refresh fast as select a,count(a) from t_mv group by a
ORA-12032: cannot use rowid column from materialized view log on "SCOTT"."T_MV"
--如下錯錯,因為單表聚集物化檢視的物化檢視日誌必須新增including new values
SQL> create materialized view mv_t refresh fast as select a,count(a) from t_mv group by a;
create materialized view mv_t refresh fast as select a,count(a) from t_mv group by a
ORA-32401: materialized view log on "SCOTT"."T_MV" does not have new values
---下面字典可以查詢物化檢視日誌各個引數的配置資訊
SQL> desc user_mview_logs;
Name Type Nullable Default Comments
------------------ ------------- -------- ------- -----------------------------------------------------------------------------------
LOG_OWNER VARCHAR2(30) Y Owner of the materialized view log
MASTER VARCHAR2(30) Y Name of the master table which changes are logged
LOG_TABLE VARCHAR2(30) Y Log table; with rowids and timestamps of rows which changed in the
master
LOG_TRIGGER VARCHAR2(30) Y Trigger on master table; fills the materialized view log
ROWIDS VARCHAR2(3) Y If YES, the materialized view log records rowid information
PRIMARY_KEY VARCHAR2(3) Y If YES, the materialized view log records primary key information
OBJECT_ID VARCHAR2(3) Y If YES, the materialized view log records object id information
FILTER_COLUMNS VARCHAR2(3) Y If YES, the materialized view log records filter column information
SEQUENCE VARCHAR2(3) Y If YES, the materialized view log records sequence information
INCLUDE_NEW_VALUES VARCHAR2(3) Y If YES, the materialized view log records old and new values (else only old values)
PURGE_ASYNCHRONOUS VARCHAR2(3) Y If YES, the materialized view log is purged asynchronously
PURGE_DEFERRED VARCHAR2(3) Y If YES, the materialized view log is purged in a deferred manner
PURGE_START DATE Y For deferred purge, the purge start date
PURGE_INTERVAL VARCHAR2(200) Y For deferred purge, the purge interval
LAST_PURGE_DATE DATE Y Date of the last purge
LAST_PURGE_STATUS NUMBER Y Status of the last purge: error code or 0 for success
NUM_ROWS_PURGED NUMBER Y Number of rows purged in the last purge
COMMIT_SCN_BASED VARCHAR2(3) Y If YES, the materialized view log is commit SCN-based
--指定開始清除日誌的時間
SQL> create materialized view log on t_mv with rowid,primary key including new values purge start with sysdate;
Materialized view log created
--同時指定下次清除日誌時間
SQL> create materialized view log on t_mv with rowid,primary key including new values purge start with sysdate next sysdate+3;
Materialized view log created
--指定清除間隔
SQL> create materialized view log on t_mv with rowid,primary key including new values purge start with sysdate repeat interval 3
2 ;
Materialized view log created
--測試基於時間戳和基於scn,預設是基於timestamp,此效能低,顯式可建立scn
SQL> create materialized view log on t_mv with commit scn;
Materialized view log created
--查詢基於scn or timestamp
SQL> select COMMIT_SCN_BASED from user_mview_logs;
COMMIT_SCN_BASED
----------------
YES
SQL> drop materialized view log on t_mv;
Materialized view log dropped
SQL> create materialized view log on t_mv;
Materialized view log created
SQL> select COMMIT_SCN_BASED from user_mview_logs;
COMMIT_SCN_BASED
----------------
NO
--測試filter column,說明master table的pk列不能用於物化檢視日誌的
filter column
SQL> create materialized view log on t_mv with sequence(a);
create materialized view log on t_mv with sequence(a)
ORA-12026: invalid filter column detected
SQL> desc t_mv;
Name Type Nullable Default Comments
---- ------- -------- ------- --------
A INTEGER
SQL> alter table t_mv add b int;
Table altered
SQL> create materialized view log on t_mv with sequence(b);
Materialized view log created
SQL> select * from user_mview_logs;
LOG_OWNER MASTER LOG_TABLE LOG_TRIGGER ROWIDS PRIMARY_KEY OBJECT_ID FILTER_COLUMNS SEQUENCE INCLUDE_NEW_VALUES PURGE_ASYNCHRONOUS PURGE_DEFERRED PURGE_START PURGE_INTERVAL LAST_PURGE_DATE LAST_PURGE_STATUS NUM_ROWS_PURGED COMMIT_SCN_BASED
------------------------------ ------------------------------ ------------------------------ ------------------------------ ------ ----------- --------- -------------- -------- ------------------ ------------------ -------------- ----------- -------------------------------------------------------------------------------- --------------- ----------------- --------------- ----------------
SCOTT T_MV MLOG$_T_MV NO YES NO YES YES NO NO NO NO
SQL> select FILTER_COLUMNS from user_mview_logs;
FILTER_COLUMNS
--------------
YES
--如下說明可同時指定多個with rowid,primary key,但不能同時指定多個filter column
SQL> create materialized view log on t_mv with rowid(b);
Materialized view log created
SQL> drop materialized view log on t_mv;
Materialized view log dropped
SQL> create materialized view log on t_mv with rowid(b),sequence;
Materialized view log created
SQL> drop materialized view log on t_mv;
Materialized view log dropped
SQL> create materialized view log on t_mv with primary key(b),rowid(b);
create materialized view log on t_mv with primary key(b),rowid(b)
ORA-00922: missing or invalid option
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-754583/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 物化檢視日誌無法正常清除的解決方法
- Oracle普通檢視和物化檢視的區別Oracle
- 用exp、imp遷移包含物化檢視日誌的資料
- Oracle物化檢視的建立及使用(二)Oracle
- Oracle物化檢視的建立及使用(一)Oracle
- 物化檢視
- oracle 11g檢視alert日誌方法Oracle
- 物化檢視(zt)
- 檢視Oracle的redo日誌切換頻率Oracle
- Linux 檢視日誌Linux
- alertmanager: 檢視日誌
- 檢視oracle的redo日誌組切換頻率Oracle
- Hyperf日誌檢視元件元件
- Logminer如何檢視日誌
- calcite物化檢視詳解
- 【MVIEW】Oracle通過物化檢視同步表資料及簡介ViewOracle
- 【ADRCI】使用ADRCI (ADR Command Interpreter) 工具檢視Oracle alert警告日誌Oracle
- docker檢視容器日誌命令Docker
- 檢視系統的日誌
- windows_weblogic日誌檢視WindowsWeb
- 【SQL】Oracle查詢轉換之物化檢視查詢重寫SQLOracle
- 資料庫的物化檢視資料庫
- 物化檢視分割槽實驗
- 自定義 Command 檢視 Laravel 日誌Laravel
- 檢視日誌的幾種形式
- mysql檢視binlog日誌詳解MySql
- eclipse設定檢視GC日誌和如何理解GC日誌EclipseGC
- 物化檢視幾個知識點
- ClickHouse 物化檢視學習總結
- NAS中如何檢視日誌記錄?
- [擴充套件包]-Laravel檢視日誌套件Laravel
- Linux 檢視日誌的命令彙總Linux
- toad使用(檢視alert日誌、Database Report)Database
- win10關機日誌檢視方法_win10電腦關機日誌怎麼檢視Win10
- ClickHouse 效能優化?試試物化檢視優化
- ClickHouse效能優化?試試物化檢視優化
- 【TUNE_ORACLE】Oracle檢查點(四)檢查點對redo日誌的影響和redo日誌大小設定建議Oracle
- oracle alert日誌Oracle
- 如何使用Journalctl檢視並操作Systemd日誌