• foreign_no_index


    column columns format a30 word_wrapped
    column tablename format a15 word_wrapped
    column constraint_name format a15 word_wrapped
    select table_name,
           constraint_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) columns
      from (select b.table_name,
                   b.constraint_name,
                   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 (select substr(table_name, 1, 30) table_name,
                           substr(constraint_name, 1, 30) constraint_name,
                           substr(column_name, 1, 30) column_name,
                           position
                      from user_cons_columns) a,
                   user_constraints b
             where a.constraint_name = b.constraint_name
               and b.constraint_type = 'R'
             group by b.table_name, b.constraint_name) cons
     where col_cnt > ALL
     (select count(*)
              from user_ind_columns i
             where i.table_name = cons.table_name
               and i.column_name in (cname1, cname2, cname3, cname4, cname5,
                    cname6, cname7, cname8) 
               and i.column_position <= cons.col_cnt
             group by i.index_name)
    /


    作者:czjie
    出处:http://www.cnblogs.com/czjie/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    【转载】超级实用且不花哨的js代码大全 -----高级应用(一)
    【 Date 对象 参考手册】
    js随机数random()方法
    【转载】js数组的操作
    【转载】js数组和json的区别
    干货----004----MySQL忘记root密码怎么办?
    PHP框架——TP_0001----ThinkPHP常用配置
    干货----003----乱码解决方法
    Python之路【第二十六篇】:xml模块
    Python之路【番外篇1】:使用Python创建照片马赛克
  • 原文地址:https://www.cnblogs.com/czjie/p/2256593.html
Copyright © 2020-2023  润新知