oracle 删除列 大数据_Oracle 删除指定sql的执行计划。
1.?oracle10g以前我們都是直接刷新共享池,但這樣數據庫中所有sql的執行計劃都會被刪掉。這種辦法也不可取,下面簡單介紹一下這種辦法:
測試版本:
SQL> select * from v$version;
BANNER CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
1
2
3
4
SQL>select *fromv$version;
BANNERCON_ID
------------------------------------------------------------------------------------------
OracleDatabase12cEnterpriseEditionRelease12.1.0.1.0-64bitProduction0
PL/SQL Release 12.1.0.1.0 - Production 0
CORE 12.1.0.1.0 Production 0
TNS for Linux: Version 12.1.0.1.0 - Production 0
NLSRTL Version 12.1.0.1.0 - Production 0
1
2
3
4
PL/SQLRelease12.1.0.1.0-Production0
CORE12.1.0.1.0Production0
TNSforLinux:Version12.1.0.1.0-Production0
NLSRTLVersion12.1.0.1.0-Production0
1.?我們執行一條簡單的sql:
SQL> select 1 from dual;
1
----------
1
1
2
3
4
5
SQL>select1fromdual;
1
----------
1
2.?此時sql的執行計劃進入shared?pool,但共享池中還有其他sql的執行計劃
SQL> select sql_id, address, hash_value, executions, loads, parse_calls, invalidations from v$sqlarea where sql_text = 'select 1 from dual';
SQL_ID ADDRESS HASH_VALUE EXECUTIONS LOADS PARSE_CALLS INVALIDATIONS
------------- ---------------- ---------- ---------- ---------- ----------- -------------
520mkxqpf15q8 000000006ECCF9C0 2866845384 1 1 1 0
SQL> select count(*) from v$sqlarea;
COUNT(*)
----------
196
1
2
3
4
5
6
7
8
SQL>selectsql_id,address,hash_value,executions,loads,parse_calls,invalidationsfromv$sqlareawheresql_text='select 1 from dual';
SQL_IDADDRESSHASH_VALUEEXECUTIONSLOADSPARSE_CALLSINVALIDATIONS
-----------------------------------------------------------------------------------
520mkxqpf15q8000000006ECCF9C028668453841110
SQL>selectcount(*)fromv$sqlarea;
COUNT(*)
----------
196
3.?然后flush一下共享池
SQL> alter system flush shared_pool;
System altered.
1
2
3
SQL>altersystemflushshared_pool;
Systemaltered.
4.?發現最開始那條sql的執行計劃已經被flush,但同時共享池所有的sql也被flush,這個代價是非常大的。不可取
SQL> select sql_id, address, hash_value, executions, loads, parse_calls, invalidations from v$sqlarea where sql_text = 'select 1 from dual';
no rows selected
SQL> select count(*) from v$sqlarea;
COUNT(*)
----------
83
1
2
3
4
5
6
7
SQL>selectsql_id,address,hash_value,executions,loads,parse_calls,invalidationsfromv$sqlareawheresql_text='select 1 from dual';
norowsselected
SQL>selectcount(*)fromv$sqlarea;
COUNT(*)
----------
83
2.?下面我們來看一下刪除指定sql的執行計劃,10.2.0.5版本以上可直接使用
1.?執行一條簡單的測試sql
SQL> select 2 from dual;
2
----------
2
1
2
3
4
5
SQL>select2fromdual;
2
----------
2
2.?查看sql在共享池的執行計劃
SQL> select sql_id, address, hash_value, executions, loads, parse_calls, invalidations
2 from v$sqlarea
3 where sql_text = 'select 2 from dual';
SQL_ID ADDRESS HASH_VALUE EXECUTIONS LOADS PARSE_CALLS INVALIDATIONS
------------- ---------------- ---------- ---------- ---------- ----------- -------------
9fusd37prv595 000000006C5D2988 3950875941 1 1 1 0
1
2
3
4
5
6
7
SQL>selectsql_id,address,hash_value,executions,loads,parse_calls,invalidations
2fromv$sqlarea
3wheresql_text='select 2 from dual';
SQL_IDADDRESSHASH_VALUEEXECUTIONSLOADSPARSE_CALLSINVALIDATIONS
-----------------------------------------------------------------------------------
9fusd37prv595000000006C5D298839508759411110
3.?將指定sql的執行計劃flush
SQL> exec sys.dbms_shared_pool.purge('000000006C5D2988,3950875941', 'c');
PL/SQL procedure successfully completed.
1
2
3
SQL>execsys.dbms_shared_pool.purge('000000006C5D2988,3950875941','c');
PL/SQLproceduresuccessfullycompleted.
4.然后我們再來查看這條sql的執行計劃的時候,已經被flush掉了
SQL> select sql_id, address, hash_value, executions, loads, parse_calls, invalidations
2 from v$sqlarea
3 where sql_text = 'select 2 from dual';
no rows selected
1
2
3
4
5
SQL>selectsql_id,address,hash_value,executions,loads,parse_calls,invalidations
2fromv$sqlarea
3wheresql_text='select 2 from dual';
norowsselected
刪除完畢。就這樣就刪掉了指定sql的執行計劃了。
轉載請注明: 版權所有,文章允許轉載,但必須以鏈接方式注明源地址,否則追究法律責任!
最后編輯:2013-09-26作者:Jerry
一個積極向上的小青年,熱衷于分享--Focus on DB,BI,ETL
總結
以上是生活随笔為你收集整理的oracle 删除列 大数据_Oracle 删除指定sql的执行计划。的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python里面两个大于号_【课堂笔记】
- 下一篇: 智能高柜机器人_丰田公司推出新型助力机器