如何找出存储过程中使用了哪些表/视图/同义词
通过Oracle查询是否可以找出存储过程使用哪些视图/同义词/表?
在 PL/SQL Developer 中,如果您折叠存储过程,它将显示“引用”,其中显示存储过程使用的所有表/视图/同义词。
我正在尝试将这个功能实现到一个会派上用场的脚本中。
想知道是否有人知道一个脚本可以为我获取存储过程使用的所有同义词/视图/表?
Through Oracle queries is it possible to find out which views/synonyms/tables a stored procedure use?
In PL/SQL Developer if you collapse out a stored procedure it will show "References" which shows all the tables/views/synonyms that the stored procedure uses.
I am trying to implement this functionality into a script which will come in handy.
Wondering if anyone knows a script that will fetch me all the synonyms/views/tables that a stored procedure uses?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您要查找的信息位于 user_dependency/all_dependencies 视图中。
The information you are looking for is in the user_dependencies/all_dependencies view.
@Rene 的答案是正确的,但我认为它需要额外的解释。从
all_dependency
中进行选择时,您可以运行如下查询,该查询应该会为您提供引用 SP 的所有对象。当它空手而归时,你可能会感到惊讶。
这是因为 oracle 是区分大小写的。这意味着您可以禁用区分大小写(如果您使用的 Oracle 版本 在比较时使用的是高于 10g r2)
或
upper
两侧希望这可以为您节省一些时间和挫败感。
The answer by @Rene is correct however I believe it needs additional explanation. When selecting from
all_dependencies
you might run query like one below that should give you all the objects that are referencing your SP.You might be surprised when it will come back empty-handed.
This is because oracle is CASE SENSITIVE. What this means is that you have to ether disable case sensitivity (if version of oracle you are using is above 10g r2)
or
upper
both sides when comparingHope this saves you some time and frustration.