根据一张表更新另外一张表

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/shujuelin/article/details/83987237
#需要更新的表

select distinct owner,table_name
  from dba_tab_columns t
 where (t.COLUMN_NAME like '%ACCT_ID%'
    ) and owner in('COMM');
    
    

#根据此表更新,comm用户

'''
select * from comm.guian_serv_map;--用户ID映射关系表
select * from comm.guian_cust_map;--客户ID映射关系表
select * from comm.guian_acct_map ;--账户ID映射关系表
select * from  comm.guian_offer_instance_map; --套餐实例ID映射关系表

'''




#1
       
select * from bill.I_SERV_LINE;

#acct
#1无分区
 update BILL.I_A_CHARGE_ADJUST_AUDIT a
    set (a.acct_id) =
        (select new_acct_id
           from comm.guian_acct_map b
          where a.acct_id = b.old_acct_id)
  where exists
  (select 1 from comm.guian_acct_map c where a.acct_id = c.old_acct_id);
  

#serv
#1无分区
update BILL.I_A_CHARGE_ADJUST_AUDIT a
   set (a.serv_id) =
       (select new_serv_id
          from comm.guian_serv_map b
         where a.serv_id = b.old_serv_id)
 where exists (select 1
          from comm.guian_serv_map c
         where a.serv_id = c.old_serv_id);

  
#2有分区
alter table bill.ACCT_OWE_B enable row movement;
update /*+parallel(a,10)+*/bill.ACCT_OWE_B a
   set (a.serv_id,a.region_id) =
       (select new_serv_id,'16000' from  comm.guian_serv_map b where a.serv_id = b.old_serv_id)
 where exists (select 1 from  comm.guian_serv_map c where a.serv_id = c.old_serv_id) ;
alter table bill.ACCT_OWE disable row movement;

猜你喜欢

转载自blog.csdn.net/shujuelin/article/details/83987237