代码对象的plsql_code_type列显示了对象的编译形式。我们对于单独的存储过程,可以不通过参数修改,而是在compile过程中,直接指定编译方式。这样也是可以将代码编译为native方式。
SQL> alter procedure p_rece_call_test compile plsql_code_type=native;
Procedure altered
SQL> select name, plsql_code_type from user_plsql_object_settings;
NAME PLSQL_CODE_TYPE
------------------------------ --------------------
P_RECE_CALL_TEST NATIVE
配置参数plsql_code_type比较简单,目前版本Oracle支持Interpreted和Native两个选项值。默认取值为Interpreted,表示将程序代码编译为解析形式。另一个就是Native,表示编译为本地代码。我们可以在session level进行灵活的配置。
SQL> alter session set plsql_code_type='native';
Session altered
SQL> alter procedure p_rece_call_test compile;
Procedure altered
SQL> select name, plsql_code_type from user_plsql_object_settings;
NAME PLSQL_CODE_TYPE
------------------------------ --------------------
P_RECE_CALL_TEST NATIVE
重新登录之后,可以将其编译回解释状态。
SQL> conn scott/tiger@ora11g;
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
Connected as scott
SQL> alter procedure p_rece_call_test compile;
Procedure altered
SQL> select name, plsql_code_type from user_plsql_object_settings;
NAME PLSQL_CODE_TYPE
------------------------------ --------------------
P_RECE_CALL_TEST INTERPRETED