FLUSH SHARED_POOL Clause
The FLUSH SHARED POOL clause lets you clear all data from the shared pool in the system global area (SGA). The shared pool stores
Cached data dictionary information and
Shared SQL and PL/SQL areas for SQL statements, stored procedures, function, packages, and triggers.
This statement does not clear shared SQL and PL/SQL areas for items that are currently being executed. You can use this clause regardless of whether your instance has the database dismounted or mounted, open or closed.
为什么keep语句,在flush后,在共享池中不存在:
SQL>alter system flush shared_pool;
System altered.
SQL> selectsql_text from v$sqlarea
2where ADDRESS='230FCC9C';
no rows selected
SQL> selectsql_text from v$sqlarea
2 where HASH_VALUE='2935929963';
no rows selected
在另外sqlplus中执行:
SQL> select address,hash_value from v$sqlarea
2where sql_text='select count(*) from t';
ADDRESSHASH_VALUE
-------- ----------
23330464 2763161912
SQL> alter system flush shared_pool;
System altered.
SQL> select address,hash_value from v$sqlarea
2where sql_text='select count(*) from t';
ADDRESSHASH_VALUE
-------- ----------
23330464 2763161912
这是在 select count(*) from t;执行过程中,执行的。发现在语句执行过程中,执行 alter system flush shared_pool;并不能被flush。即语句在执行过程中是被pin住的。