Oracle:搜索所有存储的过程/触发器/其他数据库代码?

发布于 2024-11-02 10:13:21 字数 97 浏览 1 评论 0原文

是否可以跨 Oracle 中的多个模式搜索所有编程对象(函数、存储过程、触发器等)?

我的代码中似乎未使用许多表,但我不想在不先检查的情况下删除它们来破坏任何内容。

Is it possible to search through all of the programmatic objects (functions, stored procedures, triggers, etc) across multiple schemas in Oracle?

There are a number of tables that appear to be unused in my code, but I don't want to break anything by removing them without checking first.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

不必你懂 2024-11-09 10:13:21

可以搜索对象代码——通常使用 DBMS_METADATA 包生成对象的 DDL,然后搜索 CLOB。然而,听起来这并不是您真正想要做的。

如果您只是想弄清楚系统中的任何代码是否引用了某个表,那么您通常需要使用 DBA_DEPENDENCIES 视图(或 ALL_DEPENDENCIESUSER_DEPENDENCIES 取决于您的权限和您要查找的内容的范围)。类似的内容

SELECT *
  FROM dba_dependencies
 WHERE referenced_owner = 'SCOTT'
   AND referenced_name  = 'EMP'
   AND referenced_type  = 'TABLE'

将向您显示依赖于 SCOTT 架构中的 EMP 表的所有内容。

唯一一次您想要搜索代码而不是查看 DBA_DEPENDENCIES 的情况是当您的代码正在执行动态 SQL(其中表名是硬编码的)时。但这在实践中相对不太可能。

It is possible to search through object code-- you'd generally use the DBMS_METADATA package to generate the DDL for the object and then search the CLOB. However, it doesn't sound like that's actually what you want to do.

If you are just trying to figure out whether a table is referenced by any code in your system, you would generally want to use the DBA_DEPENDENCIES view (or ALL_DEPENDENCIES or USER_DEPENDENCIES depending on your privileges and the scope of what you're looking for). Something like

SELECT *
  FROM dba_dependencies
 WHERE referenced_owner = 'SCOTT'
   AND referenced_name  = 'EMP'
   AND referenced_type  = 'TABLE'

will show you everything that depends on the EMP table in the SCOTT schema.

The only time you'd want to search code rather than looking at DBA_DEPENDENCIES would be when you had code that was doing dynamic SQL where the table name was hard-coded. But that's relatively unlikely in practice.

彩虹直至黑白 2024-11-09 10:13:21

您可以搜索 DBA_SOURCE 视图:

SELECT *
  FROM dba_source
 WHERE UPPER(text) LIKE '%YOUR_TABLE_NAME%';

You can search the DBA_SOURCE view:

SELECT *
  FROM dba_source
 WHERE UPPER(text) LIKE '%YOUR_TABLE_NAME%';
澜川若宁 2024-11-09 10:13:21

在 Toad 中执行此操作,方法是选择:

搜索 =>对象搜索

Do this in Toad by selecting:

Search => Object Search

⒈起吃苦の倖褔 2024-11-09 10:13:21

如果您有 Toad 您可以内置此操作。 (出于隐私考虑,我删除了我的架构)
蟾蜍搜索

If you had Toad you could do this built-in. (I removed my schemas for privacy)
Toad Search

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文