熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Oracle >> 正文

找出哪些table沒有primary key

2022-06-13   來源: Oracle 

  可以依照SCHEMA展出沒有設PK的TABLE
  
  def schema_name = &&owner_name
  
  col sname format a heading Schema
  col tname format a heading Table Name
  
  select
  dtowner sname
  dttable_name tname
  from
  sysdba_tables dt
  where
  dtowner like upper(&schema_name) escape \
  and
  not exists
  (select x from sysdba_constraints dc
  where dcowner = dtowner
  and dctable_name = dttable_name
  and nstraint_type = P)
  order by
  /
  
  執行結果
  
  Schema Table Name
  
  APPLE TEST_TB
  APPLE KKK
  APPLE P
  APPLE PLAN_TABLE
  APPLE QQ
  APPLE T
  APPLE T
  APPLE T
From:http://tw.wingwit.com/Article/program/Oracle/201311/17958.html
  • 上一篇文章:

  • 下一篇文章:
  • 推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.