• Script:列出没有主键或唯一索引的表


    以下脚本可以用于列出数据库中没有主键的表,已排除了系统schema:
    REM List tables with no primary key
    
    SELECT owner, table_name
      FROM dba_tables
     WHERE 1 = 1
           AND owner NOT IN
                  ('SYS',
                   'SYSTEM',
                   'SYSMAN',
                   'EXFSYS',
                   'WMSYS',
                   'OLAPSYS',
                   'OUTLN',
                   'DBSNMP',
                   'ORDSYS',
                   'ORDPLUGINS',
                   'MDSYS',
                   'CTXSYS',
                   'AURORA$ORB$UNAUTHENTICATED',
                   'XDB',
                   'FLOWS_030000',
                   'FLOWS_FILES')
    MINUS
    SELECT owner, table_name
      FROM dba_constraints
     WHERE constraint_type = 'P'
           AND owner NOT IN
                  ('SYS',
                   'SYSTEM',
                   'SYSMAN',
                   'EXFSYS',
                   'WMSYS',
                   'OLAPSYS',
                   'OUTLN',
                   'DBSNMP',
                   'ORDSYS',
                   'ORDPLUGINS',
                   'MDSYS',
                   'CTXSYS',
                   'AURORA$ORB$UNAUTHENTICATED',
                   'XDB',
                   'FLOWS_030000',
                   'FLOWS_FILES')
    /
    
    以下脚本可以用于列出数据库中没有唯一约束或索引的表,已排除了系统schema:
    REM List tables with no unique key or index 
    
    SELECT owner, table_name
      FROM dba_all_tables
     WHERE 1 = 1
           AND owner NOT IN
                  ('SYS',
                   'SYSTEM',
                   'SYSMAN',
                   'EXFSYS',
                   'WMSYS',
                   'OLAPSYS',
                   'OUTLN',
                   'DBSNMP',
                   'ORDSYS',
                   'ORDPLUGINS',
                   'MDSYS',
                   'CTXSYS',
                   'AURORA$ORB$UNAUTHENTICATED',
                   'XDB',
                   'FLOWS_030000',
                   'FLOWS_FILES')
    MINUS
    SELECT owner, table_name
      FROM dba_constraints
     WHERE constraint_type = 'U'
           AND owner NOT IN
                  ('SYS',
                   'SYSTEM',
                   'SYSMAN',
                   'EXFSYS',
                   'WMSYS',
                   'OLAPSYS',
                   'OUTLN',
                   'DBSNMP',
                   'ORDSYS',
                   'ORDPLUGINS',
                   'MDSYS',
                   'CTXSYS',
                   'AURORA$ORB$UNAUTHENTICATED',
                   'XDB',
                   'FLOWS_030000',
                   'FLOWS_FILES')
    MINUS
    SELECT owner, table_name
      FROM dba_indexes
     WHERE uniqueness = 'UNIQUE'
           AND owner NOT IN
                  ('SYS',
                   'SYSTEM',
                   'SYSMAN',
                   'EXFSYS',
                   'WMSYS',
                   'OLAPSYS',
                   'OUTLN',
                   'DBSNMP',
                   'ORDSYS',
                   'ORDPLUGINS',
                   'MDSYS',
                   'CTXSYS',
                   'AURORA$ORB$UNAUTHENTICATED',
                   'XDB',
                   'FLOWS_030000',
                   'FLOWS_FILES')
    /
    
    
  • 相关阅读:
    微信支付接口开发时遇到的问题
    记录一次特别瞎的问题。。。
    二叉树的三种遍历(java实现)
    【转】redis实现的分布式锁
    @RequestParam、@ReqeustBody、@ReponseBody认识
    同步、异步、阻塞、非阻塞
    multipart/form-data和application/x-www-form-urlencoded区别
    HTTP请求的502、504、499错误
    Nginx配置CI框架问题(Linux平台下Centos系统)
    mac中更改xampp的根目录
  • 原文地址:https://www.cnblogs.com/macleanoracle/p/2967791.html
Copyright © 2020-2023  润新知