1/7用友股份-LE支持服务业务本部技术方案--《Outline的使用》建立日期:2013-10-20修改日期:xxxx-xx-xx文档属性:客户文控编号:LE-DY-JS-2013-01142/7文档控制创建记录适用范围审阅人日期审阅签字所属部门发布范围发布人姓名所属部门发布时间内部员工伙伴客户日期作者所属部门邮件地址版本2013-10-20白晓宇技术支持部V1.0版本领域模块备注3/7目录Outline的使用...........................................................................................................44/7Outline的使用在做一个压力测试的过程中,发现主要测试的sql,在测试环境中走的执行计划跟正式的执行计划不一样,使用outline来保持一致。1为要执行的语句创建outlineCreateoutlinet_ol1forcategoryspecialonselect*fromt_testwherecol1=’00’;2导出outln用户的表3导入outln用户的表到测试环境4用sys用户更新ouline的signatureconnectsys/managerexecdbms_outln.update_signatures;启用storedoutlinealtersystemsetuse_stored_outlines=special;//指定outline的类型5停止db使用outline功能:altersystemsetuse_stored_outlines=false;disable/enable具体outline:alteroutlineol_namedisable;alteroutlineol_nameenable;删除outlinecategory:9i,10g:execdbms_outln.drop_by_cat(‘category_name’);8i:execoutln_pkg.drop_by_cat(‘category_name’);outline相关视图dba_outlines检查outline是否存在selectname,category,ownerfromdba_outlines;dba_outline_hints5/7该视图列出outline的hints内容还可以通过hashvalue,child_number来创建outlineEXECdbms_outln.create_outline(3773998222,0);在使用绑定变量的情况下,我总是遇到错误:SQL>varB1varchar2(2);SQL>exec:B1:='00';PL/SQLproceduresuccessfullycompletedB1---------00SQL>select*fromt_testwherecol1=:B1;COL1----00B1---------00SQL>Createoutlinet_ol2forcategoryspecialonselect*fromt_testwherecol1=:B1;Createoutlinet_ol2forcategoryspecialonselect*fromt_testwherecol1=:B1ORA-01036:非法的变量名/编号B1看到在指定完变量后,在通过该变量创建outline,是会提示错误的。在网上看到一个文章,创建的时候,先用抓出来的变量创建outline,然后在赋值,查询即可。见下方:SQL>Createoutlinet_ol2forcategoryspecialonselect*fromt_testwherecol1=:B6;6/7OutlinecreatedSQL>selectname,categoryfromdba_outlines;NAMECATEGORY------------------------------------------------------------T_OL2SPECIALSQL>varB6varchar2(2);SQL>exec:B6:='00';PL/SQLproceduresuccessfullycompletedB6---------00B6---------00SQL>select*fromt_testwherecol1=:B6;COL1----00B6---------00SQL>selectname,category,usedfromuser_outlines;NAMECATEGORYUSED------------------------------------------------------------------T_OL2SPECIALUNUSEDSQL>showparameterused;SQL>showparameterusedSQL>altersessionsetuse_stored_outlines=special;SessionalteredSQL>select*fromt_testwherecol1=:B6;7/7COL1----00B6---------00SQL>selectname,category,usedfromuser_outlines;NAMECATEGORYUSED------------------------------------------------------------------T_OL2SPECIALUSED可见通过上面的方式是可以对绑定变量的sql语句来设置outline的。