采用级联方式删除:
delete from  out_record where inst_id=3  cascade constraint

解决方案 »

  1.   

    用級聯方式刪除也可以
    如果你一定要找出原因的話
    首先你得確定該表的外鍵是不是只關鍵到一個表,找到PMIS.FK_23257對應的表
      

  2.   

    to:lcg412我不确定是否关联到2张表了:( 
    为了弄清这个问题我想再详细的说明一下表直接的关系以及我删除操作遇到的问题
    有4张表:
          pm_om_insts(inst_id,createdate,modifydate)---是系统表
          员工(inst_id,name)
          年份(inst_id,year,lsparent)
          月份(inst_id,month,lsparent)
          出差记录(inst_id,out_record,lsparent)
    关联关系是这样的:
          出差记录的lsparent字段和员工、月份的主键inst_id关联
          月份的lsparent字段和年份的主键inst_id关联
          年份的lsparent字段和员工的主键inst_id关联
    员工、年份、月份、出差记录的每条记录在pm_om_insts表里都有一个对应的记录且inst_id相同;
    现在的问题是:我删除用户A在pm_om_insts表里对应的记录时报错:“ORA-02292:违法完整约束条件(PMIS.FK_12157)-已找到子记录日志”我查找到外键PMIS.FK_12157所属的表是“年份”这张表
    并且我确定用户A下的所以“出差记录”、“年份”、“月份”记录都已经删除;
    请问lcg412和各位大侠可以帮我找到原因并解决这个问题吗
    PS:写了一堆也不知道表达清楚了没有!
    小妹在此先谢过了!
      

  3.   

    先确定一下FK_12157引用的主键是不是
    pm_insts 主键:inst_id把
      

  4.   

    to up:我该怎么确定呢?怎么查看呢?
      

  5.   

    select t.* from  dba_cons_columns t,dba_constraints c where 
    t.constraint_name =c.r_constraint_name and c.constraint_name ='FK_12157'
      

  6.   

    to nebulaly:
    查到一条记录
    owner     constraint_name   table_name        column_name
     PMIS   PK_PM_OM_INSTS  PM_OM_INSTS   INST_ID
    这就说明FK_12157引用的主键是pm_insts的主键:inst_id吧?!
    ps:表dba_cons_columns和dba_constraints各字段的含义是什么啊 我查他们的属性 全是English 看不懂 5555:( 
    然后我该怎么操作?
    您的qq有吗?方便给我吗
    Me:271184843