SP2-0611 and SP2-0618
今天在做SQL优化器调优准备工作的时候,刚一进去,就碰到一个报错,成功解决之后整理了下解决思路和解决方法,现在整理成文档写出来,以便后面碰到这个问题的技术朋友能够更快的解决问题。如果不正确的地方,还望不吝赐教 。
报错提示:
- SQL> set autotrace on
- SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled
- SP2-0611: Error enabling STATISTICS report
报错原因:
SQL> set autotrace on;
SP2-0618: 无法找到会话标识符。启用检查 PLUSTRACE 角色
SP2-0611: 启用STATISTICS报告时出现错误
该错误的的主要原因是由于当前用户下没有相应的PLUSTRACE角色和相应的权限。
解决方法:
1. 创建plustrace用户
2. 授予plustrace权限
3. 再次测试set autotrace on是否OK
详细步骤:
SQL> conn / as sysdba <#现以sysdba的角色登录>
SQL> drop role plustrace; <#如果数据库中没有plustrace这个角色,那么drop的时候就会报错, Role dropped. 提示没有这个用户,那你就新建一个plustrace用户>
SQL> create role plustrace;
Role created.
SQL> grant select on v_$sesstat to plustrace;
SQL> grant select on v_$statname to plustrace;
SQL> grant select on v_$mystat to plustrace;
SQL> grant plustrace to dba with admin option;
SQL> set echo off;
SQL> grant plustrace to public;
SQL> conn scott/scott;
Connected.
SQL> set autotrace on;
测试结果:
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
14 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 3956160932
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 14 | 518 | 3 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| EMP | 14 | 518 | 3 (0)| 00:00:01 |
--------------------------------------------------------------------------
Statistics
----------------------------------------------------------
205 recursive calls
0 db block gets
46 consistent gets
0 physical reads
0 redo size
1415 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
5 sorts (memory)
0 sorts (disk)
14 rows processed