建一个触发器,当数据库启动后,触发dbms_shared_pool.keep()的执行
创建该存储过程
SQL>@...\dbmspool.sql
查看该包是否创建
SQL>desc dbms_shared_pool
创建触发器
SQL>conn hr/hr;
SQL>CREATE OR REPLACE TRIGGER "HR".HR_START_TR AFTER
STARTUP ON DATABASE
begin
sys.DBMS_SHARED_POOL.KEEP('HR.ADD_JOB_HISTORY');
end;
授权给HR
grant execute on dbms_shared_pool to HR;
在关闭数据库之前验证内存中是否有add_job_history
select owner,name,type from v$db_object_cache
where owner='HR' and type='PROCEDURE';
重启数据库 再次查看下内存中是否有该存储过程
select owner,name,type from v$db_object_cache
where owner='HR' and type='PROCEDURE';