zoukankan      html  css  js  c++  java
  • 查看当前用户下没有主键也没有唯一性索引的表

    当前用户下没有主键也没有唯一性索引的表

    1、查询当前用户下没有主键的表

    select 
      from user_tables a
     where exists (select table_name
              from user_constraints b
             where b.constraint_type = 'P'
               and a.table_name = b.table_name);

    2、查询当前用户下含有唯一性索引的表

    select distinct cu.table_name
      from user_cons_columns cu, user_constraints au
     where cu.constraint_name = au.constraint_name
       and au.constraint_type = 'U') T
     where u.table_name = T.table_name;

    3、当前用户下,既没有主键也没有唯一性索引的表

    select table_name
      from user_tables u
     where not exists
     (select table_name
              from (select table_name
                      from user_tables a
                     where exists (select *
                              from user_constraints b
                             where b.constraint_type = 'P'
                               and a.table_name = b.table_name)
                    union
                    select distinct cu.table_name
                      from user_cons_columns cu, user_constraints au
                     where cu.constraint_name = au.constraint_name
                       and au.constraint_type = 'U') T
             where u.table_name = T.table_name)
       and u.table_name not like '%$%';
  • 相关阅读:
    「洛谷 NOIP 计划 2021」【学习1】降维技巧
    组合数取模 合集
    浅谈并查集
    四边形不等式优化 dp (doing)
    qbxt数学五一Day4
    qbxt五一数学Day3
    qbxt五一数学Day2
    qbxt五一数学Day1
    浅谈拉格朗日插值
    10-交换排序:冒泡排序
  • 原文地址:https://www.cnblogs.com/connected/p/10298470.html
Copyright © 2011-2022 走看看