检查给定的 DB 对象是否在 Oracle 中使用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2158731/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 19:54:11  来源:igfitidea点击:

Check if a given DB object used in Oracle?

sqloraclestored-proceduresfunctionsql-view

提问by budsiya

Hi does any one know how to check if a given DB object (Table/View/SP/Function) is used inside Oracle.

嗨,有没有人知道如何检查给定的 DB 对象(表/视图/SP/函数)是否在 Oracle 内部使用。

For example to check if the table "A" is used in any SP/Function or View definitions. I am trying to cleanup unused objects in the database.

例如,检查表“A”是否用于任何 SP/功能或视图定义。我正在尝试清理数据库中未使用的对象。

I tried the query select * from all_source WHERE TEXT like '%A%' (A is the table name). Do you thing it is safe to assume it is not being used if it does not return any results?

我尝试了查询 select * from all_source WHERE TEXT like '%A%' (A 是表名)。如果它不返回任何结果,你认为它没有被使用是否安全?

采纳答案by OMG Ponies

From this ASKTOM question:

从这个ASKTOM 问题

You'll have to enable auditing and then come back in 3 months to see.

We don't track this information by default -- also, even with auditing, it may be very possible to have an object that is INDIRECTLY accessed (eg: via a foreign key for example) that won't show up.

You can try USER_DEPENDENCIES but that won't tell you about objects referenced by code in client apps or via dynamic sql

您必须启用审核,然后在 3 个月后回来查看。

默认情况下,我们不会跟踪此信息——此外,即使使用审计,也很可能会出现一个不会显示的间接访问对象(例如:通过外键)。

您可以尝试 USER_DEPENDENCIES 但这不会告诉您客户端应用程序中的代码或通过动态 sql 引用的对象

There's code in the thread for checking ALL_SOURCE, but it's highlighted that this isn't a silver bullet.

线程中有用于检查的代码ALL_SOURCE,但要强调的是这不是灵丹妙药。