电脑故障

位置:IT落伍者 >> 电脑故障 >> 浏览文章

找出哪些table没有primary key


发布日期:2022/4/4
 

可以依照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

上一篇:重建索引(rebuild index)与sort

下一篇:使自己暂时脱离 root 的身份