dbms_shared_pool.purge 在 cursor使用时不能被清理出去
Q sequenceR triggerT typeC cursor21。
Applies To
All Users
Summary
NOTE! This note is only applicable for 10.2 and 11.1 database. For 11.2 and higher version, there are more options available for this package, please check the online documentation "PL/SQL Packages and Types Reference" for more details.
This article explains and illustrates how the PURGE procedure in the DBMS_SHARED_POOL package can be used to flush a specific object, such as a cursor, out of the Object Library Cache.
The syntax for the DBMS_SHARED_POOL.PURGE package is:
procedure purge (name varchar2, flag char DEFAULT 'P', heaps number DEFAULT 1);
Explanation: Purge the named object or particular heap(s) of the object.
Input arguments:
name: The name of the object to purge.
There are two kinds of objects:
PL/SQL objects, triggers, sequences, types and Java objects which are specified by name,
SQL cursor objects which are specified by a twopart number. The value for this identifier
is the concatenation of the 'address' and 'hash_value' columns from the v$sqlarea view.
flag: This is an optional parameter. If the parameter is not specified,
the package assumes that the first parameter is the name of a
package/procedure/function and will resolve the name. Otherwise,
the parameter is a character string indicating what kind of object
to purge the name identifies. The string is case insensitive.
The possible values and the kinds of objects they indicate are
given in the following table:
Value Kind of Object to keep
----- ----------------------
P package/procedure/function
Q sequence
R trigger
T type
JS java source
JC java class
JR java resource
JD java shared data
C cursor
heaps: heaps to purge. e.g if heap 0 and heap 6 are to be purged.
1<<0 | 1< Default is 1 i.e heap 0 which means the whole object will be purged.
Solution
SESSION 1
sqlplus scott/tiger
SQL> select ename from emp where empno=7900;
SESSION 2
sqlplus / as sysdba
SQL> select address, hash_value, executions, loads, version_count, invalidations, parse_calls
from v$sqlarea
where sql_text = 'select ename from emp where empno=7900';
ADDRESS HASH_VALUE EXECUTIONS LOADS VERSION_COUNT INVALIDATIONS PARSE_CALLS
---------------- ---------- ---------- ---------- ------------- ------------- -----------
000000007A6CF430 1052545619 1 1 1 0 1
SQL> exec dbms_shared_pool.purge ('000000007A6CF430,1052545619 ','C');
SQL> select address, hash_value, executions, loads, version_count, invalidations, parse_calls
from v$sqlarea
where sql_text = 'select ename from emp where empno=7900';
no rows selected
SESSION 1
SQL> select ename from emp where empno=7900;
SESSION 2
SQL> select address, hash_value, executions, loads, version_count, invalidations, parse_calls
from v$sqlarea
where sql_text = 'select ename from emp where empno=7900';
ADDRESS HASH_VALUE EXECUTIONS LOADS VERSION_COUNT INVALIDATIONS PARSE_CALLS
---------------- ---------- ---------- ---------- ------------- ------------- -----------
000000007A6CF430 1052545619 1 2 1 1 1
NOTE: The PURGE procedure was introduced in Oracle 11g and will be included in the 10.2.0.4 patch set release. The purge procedure is event-protected in 10.2.0.4 and needs to be enabled through event 5614566, please see <Note:751876.1> for more information. Some patches are available for some platforms with versions 10.2.0.2 and 10.2.0.3, downloadable as <Patch:5614566>.
SQL> select address, hash_value, executions, loads, version_count, invalidations, parse_calls from v$sqlarea where sql_text = 'select ename from emp where empno=7900';
ADDRESS HASH_VALUE EXECUTIONS LOADS VERSION_COUNT INVALIDATIONS
---------------- ---------- ---------- ---------- ------------- -------------
PARSE_CALLS
-----------
0000000382E80750 1052545619 1 1 1 0
1
SQL> exec dbms_shared_pool.purge ('0000000382E80750,1052545619','C');
PL/SQL procedure successfully completed.
SQL> select address, hash_value, executions, loads, version_count, invalidations, parse_calls from v$sqlarea where sql_text = 'select ename from emp where empno=7900';
no rows selected
更多推荐



所有评论(0)