时间:2021-07-01 10:21:17 帮助过:17人阅读
# 12.2之前版本
–需要用sys用户执行: sys.dbms_sqldiag_internal
–相关视图: DBA_SQL_PATCHES,hint 在description字段
–常用几个hint: GATHER_PLAN_STATISTICS / MONITOR / BIND_AWARE / IGNORE_OPTIM_EMBEDDED_HINTS
begin
sys.dbms_sqldiag_internal.i_create_patch( sql_text => V_SQL,
hint_text => ‘BIND_AWARE‘,
name => ‘sql_djzfp4cy24dx3‘);
end ;
/
# 12.2及以后版本
#创建sql patch
declare
patch_name varchar2(30);
begin
patch_name:=dbms_sqldiag.create_sql_patch(sql_id=>‘&sql_id‘ , hint_text=>‘&hint_text‘);
end ;
/
注意:hint_text的写法,要体符合 Outline Data
可能选执行 explain plan for + hint
然后通过display 的advanced 方式查询 , 注意要加引号 例: hint_text=>‘index("T"@"SEL$1")‘ 或 ‘index(@"SEL$1" "T")‘
explain plan for select /*+ index(t) */ OBJECT_NAME,OBJECT_TYPE from t where OBJECT_TYPE=‘JAVA CLASS‘;
select * from table(dbms_xplan.display(null,null,‘advanced‘));
#查看sql patch
col description format a40
col name format a30
set linesize 200
select name,to_char(created,‘yyyy-mm-dd hh24:mi:ss‘) as created
,status,force_matching,description,substr(sql_text,1,50) as sql_text
from dba_sql_patches
order by created;
#删除sql patch
exec dbms_sqldiag.drop_sql_patch(name=>‘&patch_name‘)
<wiz_tmp_tag id="wiz-table-range-border" contenteditable="false" style="display: none;">
3. SQL patch 以补丁的形式,将hint 打入到指定SQL
标签:exec data des cal 需要 pointer form none 图片