分类:
2008-10-28 18:10:10
前几天看见有人问怎么查找某个view引用了什么表,或者某个表被那些对象引用,偶当时没有注意,今天朋友问到了.
我想是有view表达这种依赖关系的,于是,偶打开 dba studio ,进入 方案---视图---sys,然后快速浏览 dba_* 这样的view,根据经验判断很多view不是所需要的,终于看到一个view : dba_dependencies,英文不大利索,猜测可能是。
SQL> desc dba_dependenciesName Null? Type
----------------------------------------- -------- --------
--------------------OWNER NOT NULL VARCHAR2(30)
NAME NOT NULL VARCHAR2(30)TYPE VARCHAR2(17)
REFERENCED_OWNER VARCHAR2(30)
REFERENCED_NAME VARCHAR2(64)
REFERENCED_TYPE VARCHAR2(17)
REFERENCED_LINK_NAME VARCHAR2(128)
DEPENDENCY_TYPE VARCHAR2(4
)select u.name, o.name,
decode(o.type#, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 7, 'PROCEDURE',8, 'FUNCTION', 9, 'PACKAGE', 10, 'NON-EXISTENT',11, 'PACKAGE BODY', 12, 'TRIGGER',13, 'TYPE', 14, 'TYPE BODY',28, 'JAVA SOURCE', 29, 'JAVA CLASS', 56, 'JAVA DATA','UNDEFINED'),
decode(po.linkname, null, pu.name, po.remoteowner), po.name,
decode(po.type#, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 7, 'PROCEDURE',8, 'FUNCTION', 9, 'PACKAGE', 10, 'NON-EXISTENT',11, 'PACKAGE BODY', 12, 'TRIGGER',13, 'TYPE', 14, 'TYPE BODY',28, 'JAVA SOURCE', 29, 'JAVA CLASS', 56, 'JAVA DATA','UNDEFINED'),
po.linkname,
decode(d.property, 2, 'REF', 'HARD')
from sys.obj$ o, sys.disk_and_fixed_objects po, sys.dependency$ d, sys.user$ u,sys.user$ puwhere o.obj# = d.d_obj#and o.owner# = u.user#and po.obj# = d.p_obj#and po.owner# = pu.user#