欢迎来到天天文库
浏览记录
ID:24996652
大小:71.18 KB
页数:4页
时间:2018-11-17
《[计算机]oracle-executionplan脚本运行配置》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、创建索引显示执行计划1.创建索引可以放在任意的表空间createindexindex_nameontable_name(xxx,xxx)tablespacetablespace_namestorage(xxxx.....)1)em下的命令CREATEINDEX"SCOTT"."INX_EMP"ON"SCOTT"."EMP"("EMPNO","JOB","DEPTNO")TABLESPACE"MYTABLESPACE";2)sqlplus命令SQL>createindexind_emponemp(s
2、al,ename);Indexcreated.scott用户创建索引不显示?SQL>2.执行创建roleplustrace的脚本1)执行脚本SQL>connsysassysdbaEnterpassword:Connected.Enterpassword:Connected.SQL>@e:oracleproduct10.1.0Db_1sqlplusadminplustrce.sql--执行创建roleplustrace的脚本//安装的oracle路径在e盘---脚本dba自动创建的权限
3、SQL>SQL>droproleplustrace;Roledropped.SQL>createroleplustrace;Rolecreated.SQL>SQL>grantselectonv_$sesstattoplustrace;Grantsucceeded.SQL>grantselectonv_$statnametoplustrace;Grantsucceeded.SQL>grantselectonv_$mystattoplustrace;Grantsucceeded.SQL>grantpl
4、ustracetodbawithadminoption;Grantsucceeded.SQL>SQL>setechooff---脚本dba自动创建的权限2)给public执行计划的权限DBA用户首先被授予了plustrace角色,然后我们可以把plustrace授予public这样所有用户都将拥有plustrace角色的权限.SQL>grantplustracetopublic;//如果你需要限制Autotrace权限,可以把对public的授权改为对特定user的授权。然后我们就可以使用Auto
5、Trace的功能了.---------------赋角色plustrace给public,所有普通用户都具有此角色/*一般情况下不用配置上面的内容*/这个角色会让普通用户可以查看到统计信息等。-----------------普通用户没有该角色时在SQL>settimeon10:09:20SQL>setautotraceonSP2-0618:CannotfindtheSessionIdentifier.CheckPLUSTRACEroleisenabledSP2-0611:Errorenablin
6、gSTATISTICSreport提示么有角色权限,所在只能看到ExecutionPlan的信息,看不到统计信息。----------------3.执行创建plan_table的脚本SQL>@e:oracleproduct10.1.0Db_1RDBMSADMINutlxplan.sql;--SQL>grantallonplan_tabletopublic;--赋plan_table上的all权限给public,所有普通用户都具有此权限Grantsucceeded.Tablecrea
7、ted.SQL>4.Sql*plus运行错误的原因可能你第一次在SQL*PLUS中运行SETAUTOTRACEON会得到如下错误:SQL>setautotraceon;SP2-0613:无法验证PLAN_TABLE格式或实体SP2-0611:启用EXPLAIN报告时出错SP2-0618:无法找到会话标识符。启用检查PLUSTRACE角色SP2-0611:启用STATISTICS报告时出错这是因为你没有PLUSTRACE权限1).运行plustrce.sql,必须用SYS用户或者再SVRMGRL中S
8、QL>@e:oracleproduct10.1.0Db_1sqlplusadminplustrce.sql2).GrantPLUSTRACEtoSMS3).在SMS的模式下运行@e:oracleproduct10.1.0Db_1RDBMSADMINutlxplan.sql;然后就可以用setautotraceon了5.普通用户执行计划SQL>connectscott//普通用户SQL>setautotraceon--显示执行计划和统计信息SQL>seta
此文档下载收益归作者所有