升級遷移前,存儲過程統計各個用戶下表的數據量,和遷移後的比對

  使用xtts升級數據庫10.2.0.5到11.2.0.4後,比對兩邊數據量是否一致。sql

  首先,在源端新建一張表:數據庫

  

CREATE TABLE TMP_TAB_COUNT(owner VARCHAR2(30) ,TABLE_NAME VARCHAR2(50),TABLE_CNT_O INT) tablespace users;

  使用如下存儲過程,查詢用戶ntcis下全部表的數據量:spa

begin
 for tb in (select table_name 
 from dba_tables 
 where owner='DSG'
 and TEMPORARY='N' 
) LOOP
 execute immediate 
 'insert into TMP_TAB_COUNT(owner,table_name,table_cnt_o)  select ''DSG'' as owner,'''
 ||tb.table_name
 ||''',(select count(*) from DSG.'
 ||'"'
 ||tb.table_name
 ||'"'
 ||') from dual';
 END LOOP;
 COMMIT;
END;
/

或者手動插入owner:code

begin
 for tb in (select table_name 
 from dba_tables 
 where owner='NTCIS'
 and TEMPORARY='N' 
) LOOP
 execute immediate 
 'insert into TMP_TAB_COUNT1(table_name,table_cnt_o) select '''
 ||tb.table_name
 ||''',(select count(*) from NTCIS.'
 ||'"'
 ||tb.table_name
 ||'"'
 ||') from dual';
 END LOOP;
 COMMIT;
END;
/
UPDATE TMP_TAB_COUNT1 SET OWNER='NTCIS' WHERE OWNER IS NULL;
commit;

  同理,升級完成後,在目標端也進行相同的查詢,再建立dblink使用minus能夠查看到有異常的數據量:blog

select * from tmp_tab_count minus select * from tmp_tba_count1@desttns;
相關文章
相關標籤/搜索