--GDOSS
--OSS
truncate table db_tables;
begin
  tj_data_local('GDOSS');
  end;

--ODS
truncate table oss_tables;
truncate table ods_tables;
begin
  tj_data_local('GDOSS');
  end;

insert into oss_tables select * from db_tables@link_oss;

--创建差别表
  create table  gdoss_ogg_dif  as  select a.table_owner, a.table_name, a.cnt ods_cut, b.cnt oss_cnt, a.cnt - b.cnt dif
    from ods_tables a, oss_tables b
   where a.table_owner = b.table_owner
     and a.table_name = b.table_name
     and a.cnt - b.cnt < 0 order by a.cnt - b.cnt;
truncate table gdoss.FAULT_ONETIME_REPORT_DATA;
insert into gdoss.FAULT_ONETIME_REPORT_DATA select * from gdoss.FAULT_ONETIME_REPORT_DATA@link_oss;

--GDDSW
--源端：
truncate table db_tables;
begin
  tj_data_local('GDDSW');
  end;

--ODS:
truncate table gddsw_tab_local;
truncate table gddsw_tab_network;

begin
  tj_data_local_gddsw('GDDSW');
  end;

insert into gddsw_tab_network select * from db_tables@link_gddsw;  

 --创建差别表 
  create table  gddsw_ogg_dif as  select a.table_owner, a.table_name, a.cnt ods_cut, b.cnt oss_cnt, a.cnt - b.cnt dif
    from gddsw_tab_local a, gddsw_tab_network b
   where a.table_owner = b.table_owner
     and a.table_name = b.table_name
     and a.cnt - b.cnt < 0 order by a.cnt - b.cnt;
truncate table gddsw.RPT_ONLINE     ;
insert into gddsw.RPT_ONLINE select * from gddsw.RPT_ONLINE@link_gddsw;

--BOSS
--gboss
truncate table goldengate.db_tables;
insert into goldengate.db_tables 
select 'sys_servst' tablename, count(1) cnt
  from boss_crm.sys_servst
union all
select 'sys_cust' tablename, count(1) cnt
  from boss_crm.sys_cust
union all
select 'SYS_CUST_DEV' tablename, count(1) cnt
  from boss_crm.SYS_CUST_DEV
union all
select 'RES_DEVICE' tablename, count(1) cnt
  from boss_crm.RES_DEVICE
union all
select 'RES_HOUSE' tablename, count(1) cnt
  from boss_crm.RES_HOUSE
union all
select 'BIZ_LOG' tablename, count(1) cnt
  from boss_crm.BIZ_LOG
union all
select 'BIZ_FEE' tablename, count(1) cnt
  from boss_crm.BIZ_FEE
union all
select 'BIZ_SERVST_DET' tablename, count(1) cnt
  from boss_crm.BIZ_SERVST_DET
union all
select 'R_SYS_SERVST' tablename, count(1) cnt
  from boss_crm.R_SYS_SERVST
union all
select 'BIZ_DEVREPLACE' tablename, count(1) cnt
  from boss_crm.BIZ_DEVREPLACE
union all
select 'sys_DIGIT_ASSIST' tablename, count(1) cnt
  from boss_crm.sys_DIGIT_ASSIST
union all
select 'sys_VOD_ASSIST' tablename, count(1) cnt
  from boss_crm.sys_VOD_ASSIST
union all
select 'BIZ_PRODUCT' tablename, count(1) cnt
  from boss_crm.BIZ_PRODUCT
union all
select 'BIZ_SALESPKG' tablename, count(1) cnt
  from boss_crm.BIZ_SALESPKG
union all
select 'sys_CM_ASSIST' tablename, count(1)  cnt
from boss_crm.sys_CM_ASSIST; 
commit;

--ODS:
truncate table boss_tab_local;
truncate table boss_tab_network;
insert into boss_tab_local
select 'sys_servst' tablename, count(1) cnt
  from boss_crm.sys_servst
union all
select 'sys_cust' tablename, count(1) cnt
  from boss_crm.sys_cust
union all
select 'SYS_CUST_DEV' tablename, count(1) cnt
  from boss_crm.SYS_CUST_DEV
union all
select 'RES_DEVICE' tablename, count(1) cnt
  from boss_crm.RES_DEVICE
union all
select 'RES_HOUSE' tablename, count(1) cnt
  from boss_crm.RES_HOUSE
union all
select 'BIZ_LOG' tablename, count(1) cnt
  from boss_crm.BIZ_LOG
union all
select 'BIZ_FEE' tablename, count(1) cnt
  from boss_crm.BIZ_FEE
union all
select 'BIZ_SERVST_DET' tablename, count(1) cnt
  from boss_crm.BIZ_SERVST_DET
union all
select 'R_SYS_SERVST' tablename, count(1) cnt
  from boss_crm.R_SYS_SERVST
union all
select 'BIZ_DEVREPLACE' tablename, count(1) cnt
  from boss_crm.BIZ_DEVREPLACE
union all
select 'sys_DIGIT_ASSIST' tablename, count(1) cnt
  from boss_crm.sys_DIGIT_ASSIST
union all
select 'sys_VOD_ASSIST' tablename, count(1) cnt
  from boss_crm.sys_VOD_ASSIST
union all
select 'BIZ_PRODUCT' tablename, count(1) cnt
  from boss_crm.BIZ_PRODUCT
union all
select 'BIZ_SALESPKG' tablename, count(1) cnt
  from boss_crm.BIZ_SALESPKG
union all
select 'sys_CM_ASSIST' tablename, count(1)  cnt
from boss_crm.sys_CM_ASSIST; 
commit;

insert into boss_tab_network select * from db_tables@link_boss;
--比较
 select a.table_name, a.cnt ods_cnt, b.cnt boss_cnt, a.cnt - b.cnt dif
    from boss_tab_local a, boss_tab_network b
   where  a.table_name = b.table_name
     and a.cnt - b.cnt < 0 order by a.cnt - b.cnt;

--BIL
select count(1) from     BOSS_BIL.BIL_PAYED; 
select count(1) from    BOSS_BIL.BIL_PAYDETAIL; 

--EDW
select count(1) from    BOSS_CRM.BIZ_PRODUCT_DET;
select count(1) from    NODS.TO_BIZ_PRODUCT_DET_DG;
