哪些情况会导致 Oracle 软件包无效?

2021-12-24 00:00:00 package dependencies oracle plsql

产生这个问题的场景:

我们有一个包是另一个包的依赖项,有时对父"包进行更改会导致依赖包无效,但有时不会.

We have a package that is a dependency of another package, sometimes making changes to the "parent" package causes the dependent package to become invalid, but sometimes it doesn't.

之前它让我们大吃一惊.

It has caught us by surprise before.

简单地了解导致失效的原因非常有用,这样我就可以预测/计划它.

It would be very useful to simply understand what causes invalidation so I could predict/plan for it.

推荐答案

更改包所依赖的任何对象(例如表、视图、触发器、其他包)将自动将包标记为无效.正如上面的 tuinstoel 所指出的,Oracle 足够聪明,可以在第一次使用包时重新编译它.

Changing anything object that a package relies upon (e.g. tables, views, triggers, other packages) will automatically mark the package as invalid. As tuinstoel notes above, Oracle is smart enough to recompile the package when it is first used.

如果您对此感到担心,则每次进行架构更改(例如表、视图、触发器、过程)时,请运行 DBMS_UTILITY.compile_schema(或让您的 DBA 执行此操作).这将强制编译所有包,并让您知道哪里或是否有错误,然后才能找到它们.

If you are concerned about this, every time you make schema changes (e.g. tables, views, triggers, procedures), run a DBMS_UTILITY.compile_schema (or have your DBA do it). This will force compile all the packages and let you know where, or if, there are errors before you find them the hard way.

相关文章