一次导如数据库时主表数据丢失的解决过程

报错如下

查出主表少的数据

select *
  from GUPROPOSALCLAUSES t,GUPROPOSALMAIN tt
         where t.PROPOSALNO = tt.PROPOSALNO(+)
           and tt.PROPOSALNO is null

然后删除子表中多的那些数据,当然也可以从源库找到主表缺少的数据,然后添加进来          

delete from GUPOLICYCOPYPAYMENTPLANDETAIL
       where policyno='U604131516000277';

下面是一个找出各种主外键关系的表

select (select a.table_name
         from user_constraints a
          where a.constraint_name = c.r_constraint_name) 主表表名,
          c.r_constraint_name 主表主键键约束名,
          c.table_name 从表表名,
          c.constraint_name 从表外键约束名,c.*
          from user_constraints c
          where c.constraint_type = 'R' and c.constraint_name='FK_GUPOLICY_R56';


 
 
 

原文地址:https://www.cnblogs.com/zydev/p/5286700.html