Oracle MV テスト 時間優先 競合発生なし

Oracle において MV マテリアライズド・ビュー とは以下を示します。

マテリアライズド・ビュー タイムスタンプによるの優先順位

  1. タイムスタンプ競合解消メソッドを定義したオブジェクト
     scott_rep.empsecond
    
  2. オブジェクトのレコードの確認
     conn scott_rep/tiger
     select idsecond,namesecond,
     to_char(timestamp,'yyyy.mm.dd hh24:mi:ss')
     from empsecond;
    

マテリアライズド・ビュー テスト手順

  1. 現在時刻の確認
     select to_char(sysdate, 'yyyy.mm.dd hh24:mi:ss') now
       from dual;
    
  2. 下記テスト内容をそれぞれ実施
    1. マスターサイト 挿入→結果:○
    2. レプリケーションサイト 挿入→結果:○
    3. マスターサイト 更新→結果:○
    4. レプリケーションサイト 更新→結果:○
    5. マスターサイト 行削除→結果:○
    6. レプリケーションサイト 行削除→結果:○
    7. (競合あり) 両サイト更新。マスターサイト表を遅くcommit。→結果:○
    8. (競合あり) 両サイト更新。レプリケーションサイト表を遅くcommit。→結果:○
    9. (競合あり) マスターサイト挿入、レプリケーションサイト挿入。レプリケーションサイト遅くcommit。→結果:競合発生
  3. 高速リフレッシュの実行(レプリケーションサイトで実行)
     conn mviewadmin/mviewadmin
     execute dbms_refresh.refresh('mviewadmin.scottrep_refg');
    
  4. 競合の確認(マスターサイトで実行)
     conn repadmin/repadmin
     select deferred_tran_id,origin_tran_db,
       start_time,error_msg,destination
       from deferror;
    
  5. 競合の確認(レプリケーションサイトで実行)
     conn mviewadmin/mviewadmin
     select deferred_tran_id,origin_tran_db,
       start_time,error_msg,destination
       from deferror;
    

※下記テスト内容詳細

  1. マスターサイト 挿入→結果:○
     conn scott_rep/tiger
     insert into empsecond (idsecond,namesecond)
     values (1200,'SMI_MAS');
     commit
     ;
    
  2. レプリケーションサイト 挿入→結果:○
     conn scott_rep/tiger
     insert into empsecond (idsecond,namesecond)
     values (2345,'SMI_REP');
     commit
     ;
    
  3. マスターサイト 更新→結果:○
     update empsecond set namesecond = 'SMI_M_UP'
     where idsecond = 1200
     ;
     commit
     ;
    
  4. レプリケーションサイト 更新→結果:○
     update empsecond set namesecond = 'SMI_RE_UP'
     where idsecond = 2345
     ;
     commit
     ;
    
  5. マスターサイト 行削除→結果:○
     delete from empsecond
     where idsecond = 1200
     ;
     commit
     ;
    
  6. レプリケーションサイト 行削除→結果:○
     delete from empsecond
     where idsecond = 2345
     ;
     commit
     ;
    
  7. (競合あり) 両サイト更新。マスターサイト表を遅くcommit。→結果:○
     ■■replication
     update empsecond set namesecond = 'SMI_R_',timestamp=sysdate
     where idsecond = 1200
     ;
     commit
     ;
    
     □■master
     update empsecond set namesecond = 'SMI_M_'
     where idsecond = 1200
     ;
     commit
     ;
    
  8. (競合あり) 両サイト更新。レプリケーションサイト表を遅くcommit。→結果:○
     □■master
     update empsecond set namesecond = 'SMI_M_UP5'
     where idsecond = 1200
     ;
     commit
     ;
    
     ■■replication
     update empsecond set namesecond = 'SMI_R_UP2',timestamp=sysdate
     where idsecond = 1200
     ;
     commit
     ;
    
  9. (競合あり) マスターサイト挿入、レプリケーションサイト挿入。レプリケーションサイト遅くcommit。→結果:競合発生
     □■master
     conn scott_rep/tiger
     insert into empsecond (idsecond,namesecond) values (7777,'W_MAS');
     commit
     ;
    
     ■■replication
     conn scott_rep/tiger
     insert into empsecond (idsecond,namesecond,timestamp) values (7777,'W_REP',sysdate);
     commit
     ;
    
    1. 競合解消→マスターサイト表を削除。結果は、ロールバックしてレプリケーションサイト表もない。
       □■master stop
       conn repadmin/repadmin
       exec dbms_reputil.replication_off;
      
       □■master delete
       conn scott_rep/tiger
       delete from empsecond
       where idsecond=7777;
       commit;
      
       □■master start
       conn repadmin/repadmin
       exec dbms_reputil.replication_on;
      
       □■master deferror
       conn repadmin/repadmin
       exec dbms_defer_sys.delete_error(null,null)
      
       □■master 競合の確認
       conn repadmin/repadmin
       select deferred_tran_id,origin_tran_db,
       start_time,error_msg,destination
       from deferror;
      

ご訪問頂き有難う御座います。 当サイトを効率良く使うためにまずは FrontPage を見て下さい。 検索方法、一覧表示などの各情報を纏めています。
当サイトの説明 → Frontpage