Oracle autotrace参数详解
SQL> set autotrace traceonly explain
SP2-0613: 无法验证 PLAN_TABLE 格式或实体
SP2-0611: 启用EXPLAIN报告时出错
解决方法:
1. 以SYS用户登录
CONNECT / @ as SYSDBA ;
1. 创建PLAN_TABLE(如果未创建)
运行utlxplan.sql(Oracle_HOME/rdbms/admin下)脚本;
2. 创建plustrace角色(如果未创建)
执行plustrce.sql(ORACLE_HOME/sqlplus/admin/plustrce.sql)脚本;
3. 将plustrace role赋给当前用户
grant plustrace to scott;或grant plustrace to public;
具体操作
1、创建基础表
运行$ORACLE_HOME/rdbms/admin/utlxplan脚本来创建plan_table
scott@ORCL> conn system/RedHat --使用system帐户登陆
Connected.
system@ORCL> start $ORACLE_HOME/rdbms/admin/utlxplan --执行utlxplan脚本
Table created.
system@ORCL> create public synonym plan_table for plan_table; --为表plan_table创建公共同义词
Synonym created.
system@ORCL> grant all on plan_table to public; --将同义词表plan_table授予给所有用户
Grant succeeded.
2、创建角色
运行$ORACLE_HOME/sqlplus/admin/plustrce.sql脚本
system@ORCL> conn / as sysdba --使用sysdba帐户登陆
onnected.
sys@ORCL> start $ORACLE_HOME/sqlplus/admin/plustrce.sql --执行创建角色的脚本
sys@ORCL> create role plustrace;
Role created.
sys@ORCL>
sys@ORCL> grant select on v_$sesstat to plustrace;
Grant succeeded.
sys@ORCL> grant select on v_$statname to plustrace;
Grant succeeded.
sys@ORCL> grant select on v_$mystat to plustrace;
Grant succeeded.
sys@ORCL> grant plustrace to dba with admin option;
Grant succeeded.