文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

外键缺索引检查脚本

2023-06-05 13:29

关注

  • --以ZLHIS用户执行
  • Select Child_Table, Foreign_Key,
  •        Cname1 || Nvl2(Cname2, ',' || Cname2, Null) || Nvl2(Cname3, ',' || Cname3, Null) ||
  •         Nvl2(Cname4, ',' || Cname4, Null) || Nvl2(Cname5, ',' || Cname5, Null) || Nvl2(Cname6, ',' || Cname6, Null) ||
  •         Nvl2(Cname7, ',' || Cname7, Null) || Nvl2(Cname8, ',' || Cname8, Null) Columns, Main_Table, Primary_Key,
  •        Decode(p.Table_Name, Null, 0, 1) Key_Rows
  • From (Select Col_Cnt, Main_Table, Primary_Key, Child_Table, Foreign_Key,
  •               Cname1 || Nvl2(Cname2, ',' || Cname2, Null) || Nvl2(Cname3, ',' || Cname3, Null) ||
  •                Nvl2(Cname4, ',' || Cname4, Null) || Nvl2(Cname5, ',' || Cname5, Null) || Nvl2(Cname6, ',' || Cname6, Null) ||
  •                Nvl2(Cname7, ',' || Cname7, Null) || Nvl2(Cname8, ',' || Cname8, Null) As Columns, Cname1, Cname2, Cname3,
  •               Cname4, Cname5, Cname6, Cname7, Cname8
  •        From (Select c.Table_Name As Main_Table, b.r_Constraint_Name As Primary_Key, b.Table_Name As Child_Table,
  •                      b.Constraint_Name As Foreign_Key, Max(Decode(Position, 1, Column_Name, Null)) Cname1,
  •                      Max(Decode(Position, 2, Column_Name, Null)) Cname2, Max(Decode(Position, 3, Column_Name, Null)) Cname3,
  •                      Max(Decode(Position, 4, Column_Name, Null)) Cname4, Max(Decode(Position, 5, Column_Name, Null)) Cname5,
  •                      Max(Decode(Position, 6, Column_Name, Null)) Cname6, Max(Decode(Position, 7, Column_Name, Null)) Cname7,
  •                      Max(Decode(Position, 8, Column_Name, Null)) Cname8, Count(*) Col_Cnt
  •               From User_Cons_Columns A, User_Constraints B, User_Constraints C
  •               Where a.Constraint_Name = b.Constraint_Name And b.Status = 'ENABLED' And b.Constraint_Type = 'R' And
  •                b.r_Constraint_Name <> '部门表_PK' And b.r_Constraint_Name = c.Constraint_Name And
  •                c.Table_Name Not In (Select 表名 From zlBaseCode)
  •               Group By c.Table_Name, b.Table_Name, b.Constraint_Name, b.r_Constraint_Name)) Cons, User_Tab_Statistics S,
  •      (Select Table_Name
  •        From User_Tables
  •        Where Table_Name In (Select 表名 From zlBakTables Union All Select 表名 From Zlbigtables) Or Table_Name Like '%病人%') P
  • Where Cons.Child_Table = s.Table_Name(+) And Cons.Main_Table = p.Table_Name(+) And Not Exists
  •  (Select 1
  •        From (Select Table_Name,
  •                      Cname1 || Nvl2(Cname2, ',' || Cname2, Null) || Nvl2(Cname3, ',' || Cname3, Null) ||
  •                       Nvl2(Cname4, ',' || Cname4, Null) || Nvl2(Cname5, ',' || Cname5, Null) ||
  •                       Nvl2(Cname6, ',' || Cname6, Null) || Nvl2(Cname7, ',' || Cname7, Null) ||
  •                       Nvl2(Cname8, ',' || Cname8, Null) As Columns
  •               From (Select i.Table_Name, Max(Decode(Column_Position, 1, Column_Name, Null)) Cname1,
  •                             Max(Decode(Column_Position, 2, Column_Name, Null)) Cname2,
  •                             Max(Decode(Column_Position, 3, Column_Name, Null)) Cname3,
  •                             Max(Decode(Column_Position, 4, Column_Name, Null)) Cname4,
  •                             Max(Decode(Column_Position, 5, Column_Name, Null)) Cname5,
  •                             Max(Decode(Column_Position, 6, Column_Name, Null)) Cname6,
  •                             Max(Decode(Column_Position, 7, Column_Name, Null)) Cname7,
  •                             Max(Decode(Column_Position, 8, Column_Name, Null)) Cname8
  •                      From User_Ind_Columns I, User_Indexes A, User_Constraints B
  •                      Where a.Index_Name = i.Index_Name And a.Status = 'VALID' And i.Table_Name = b.Table_Name And
  •                            b.Constraint_Type = 'R' And b.r_Constraint_Name <> '部门表_PK'
  •                      Group By i.Table_Name, i.Index_Name)) Inds
  •        Where Instr(',' || Inds.Columns, ',' || Cons.Columns) = 1 And Cons.Child_Table = Inds.Table_Name)
  • Order By Key_Rows Desc, s.Num_Rows Desc Nulls Last
  • 免责声明:

    ① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

    ② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

    软考中级精品资料免费领

    • 历年真题答案解析
    • 备考技巧名师总结
    • 高频考点精准押题
    • 资料下载
    • 历年真题
    • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

      难度     813人已做
      查看
    • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

      难度     354人已做
      查看
    • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

      难度     318人已做
      查看
    • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

      难度     435人已做
      查看
    • 2024年上半年系统架构设计师考试综合知识真题

      难度     224人已做
      查看

    相关文章

    发现更多好内容
    咦!没有更多了?去看看其它编程学习网 内容吧