在Oracle SQL开发人员GUI中,我打开了一个表,并显示了一个带有属性的窗口。这是一个名为Dependencies
的窗口选项卡。
我找到了这个查询:
select OWNER
, name
, type
, referenced_name
, referenced_type
from all_dependencies;
但是没有像Oracle SQL Developer那样为所有所有者显示输出。
如何通过与所有所有者的查询SQL获取这些结果?
谢谢!
答案 0 :(得分:1)
使用如下查询:
select owner, name, type, referenced_owner, referenced_name, referenced_type
from dba_dependencies
where referenced_owner = user and referenced_name = 'YOUR_TABLE_NAME';
或使用绑定变量:
var object_owner varchar2(30);
var object_name varchar2(30);
exec :object_owner := user;
exec :object_name := 'YOUR_TABLE_NAME';
select owner, name, type, referenced_owner, referenced_name, referenced_type
from dba_dependencies
where referenced_owner = :object_owner and referenced_name = :object_name ;
您实际上可以看到SQL Developer在后台运行的查询。如果你转到视图菜单并选择日志,或点击 Ctrl Shift L (假设你正在使用Windows)你&# 39; ll得到一个停靠窗口,默认标题为" Messages - Log"。在底部是两个标签,其中包含"消息"选择。如果您点击"语句"相反,你可以看到使用的语句和绑定变量。
在这种情况下,刷新依赖项选项卡时会发出三个语句,其中两个是我上面显示的内容的变体 - 它们会获得更多列,并检查两种方式的依赖关系:
select owner, name, type, referenced_owner, referenced_name, referenced_type ,
owner sdev_link_owner, name sdev_link_name, type sdev_link_type
from Dba_DEPENDENCIES
where referenced_owner = :OBJECT_OWNER and referenced_name = :OBJECT_NAME
select owner, name, type, referenced_owner, referenced_name, referenced_type ,
referenced_owner sdev_link_owner, referenced_name sdev_link_name, referenced_type sdev_link_type
from Dba_DEPENDENCIES
where owner = :OBJECT_OWNER and name = :OBJECT_NAME
如果你想弄清楚你能看到什么,那么它们是一个很好的起点。
如果您作为没有查看dba_dependencies
表所需权限的用户进行连接,则SQL Developer会返回all_dependencies
:
select owner, name, type, referenced_owner, referenced_name, referenced_type ,
owner sdev_link_owner, name sdev_link_name, type sdev_link_type
from ALL_DEPENDENCIES
where referenced_owner = :OBJECT_OWNER and referenced_name = :OBJECT_NAME
select owner, name, type, referenced_owner, referenced_name, referenced_type ,
referenced_owner sdev_link_owner, referenced_name sdev_link_name, referenced_type sdev_link_type
from Dba_DEPENDENCIES
where owner = :OBJECT_OWNER and name = :OBJECT_NAME
仅显示有关您具有选择/执行权限的对象的信息。在上面显示的第一个查询中,您只需将dba_dependencies
更改为all_dependencies
即可查看等效(可见)结果。
如果您以与SQL Developer相同的用户手动运行SQL,则会看到相同的结果。