4.使對象的相關定義,執行計劃或執行代碼駐留到shared_pool(library cache)裏(表是駐留到數據字典裏面的),不受LRU算法的限制,不會被清除
主要是看這個字段kept爲也是則不受LRU算法的限制
SQL> exec dbms_shared_pool.keep('SCOTT.P1');
SQL> select OWNER,NAME,KEPT from v$db_object_cache where owner='SCOTT';
OWNER NAME KEPT
------------------------------ ------------------------------ --------------------
SCOTT DBMS_APPLICATION_INFO NO
SCOTT P1 YES
SCOTT DBMS_SHARED_POOL NO
SCOTT DUAL NO
SCOTT SCOTT NO
執行清空shared_pool的操作
alter system flush shared_pool;
SQL> select OWNER,NAME,KEPT from v$db_object_cache where owner='SCOTT';
OWNER NAME KEPT
------------------------------ ------------------------------ --------------------
SCOTT P1 YES
SCOTT SCOTT NO
取消駐留,重新受LRU算法的管理
SQL> exec dbms_shared_pool.unkeep('SCOTT.P1');
PL/SQL procedure successfully completed.
清空一下shared_pool
SQL> alter system flush shared_pool;
System altered.
SQL> select OWNER,NAME,KEPT from v$db_object_cache where owner='SCOTT';
OWNER NAME KEPT
------------------------------ ------------------------------ --------------------
SCOTT SCOTT NO