通过oracle普通用户想打开set auotrace功能发现报如下错误

SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled

SP2-0611: Error enabling STATISTICS report


SQL> conn scott/tiger

Connected.

SQL> set autotrace on;

SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled

SP2-0611: Error enabling STATISTICS report

连接在sys用户下发现没有这个角色

SQL> conn / as sysdba

Connected.

SQL> grant pustrace to scott;

ERROR at line 1:

ORA-01919: role 'PUSTRACE' does not exist


通过执行下以脚本创建此角色

SQL> @?/sqlplus/admin/plustrce.sql

SQL> 

SQL> drop role plustrace;

drop role plustrace

          *

ERROR at line 1:

ORA-01919: role 'PLUSTRACE' does not exist



SQL> create role plustrace;


Role created.


SQL> 

SQL> grant select on v_$sesstat to plustrace;


Grant succeeded.


SQL> grant select on v_$statname to plustrace;


Grant succeeded.


SQL> grant select on v_$mystat to plustrace;


Grant succeeded.


SQL> grant plustrace to dba with admin option;


Grant succeeded.


现在就可以在将plustrace角色赋予给其他用户了