在阅读 PLSQL 书籍时,我偶然发现了这段代码:
ALTER PROCEDURE pls_test COMPILE PLSQL_CODE_TYPE=INTERPRETED;
您能解释一下它与普通编译有何不同吗?我没能在书中找到答案。
谢谢!
最佳答案
Oracle 支持两种不同的编译模式:INTERPRETED 和 NATIVE。
INTERPRETED 是默认模式,与存储 PL/SQL (Oracle 7) 同时引入:
... each PL/SQL program unit is compiled into an intermediate form, machine-readable code (MCode). The MCode is stored in the database dictionary and interpreted at run time
在您展示的代码中,INTERPRETED 部分是多余的,因为它对应于默认编译模式(除非命令是针对默认已更改的服务器执行的)。
NATIVE 是在 Oracle 9 中引入的,然后在以下版本中进行了增强和简化:
SQL modules (packages, triggers, procedures, function, and types) .. are compiled... into native code residing in shared libraries. The procedures are translated into C code, then compiled with a C compiler and dynamically linked into the Oracle process.
这导致执行时间更快,因为在运行时不需要解释:在 Oracle 10g 中预测改进因子从 1.04 到 2.4。
作为结论:除非你有充分的理由,否则你想使用 NATIVE 而不是 INTERPRETED...
有关更多详细信息和可能的迁移路径,请阅读 this Oracle 10g FAQ paper和 this post on Oracle blog .
关于sql - 按解释编译存储过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53973307/