转载自:http://blog.csdn.net/zhengwei125/article/details/50128975
sql> conn zw/zw
Connected.
sql> set autotrace traceonly;
SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled
SP2-0611: Error enabling STATISTICS report
sql>
方法一:
grant dba to zw;
sql> conn zw/zw
Connected.
sql> set autotrace traceonly;
方法二:
sql> grant select on v_$sesstat to zw;
sql> grant select on v_$statname to zw;
sql> grant select on v_$mystat to zw;
sql> conn zw/zw
Connected.
sql> set autotrace traceonly;
sql>
回收权限
sql>revoke select on v_$sesstat from zw;
sql>revoke select on v_$statname from zw;
sql>revoke select on v_$mystat from zw;
又不能用了
sql> conn zw/zw
Connected.
sql> set autotrace traceonly;
SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled
SP2-0611: Error enabling STATISTICS report
然后再使用 set autotrace on 就不出有错误了。
方法三:
创建plustrace角色,然后将角色赋给特定用户。Oracle已经提供了角色plustrace的创建脚本
把角色赋权给zw用户
sql> grant plustrace to zw;
sql> conn zw/zw
Connected.
sql> set autotrace traceonly;
把角色赋予给所有用户
sql> grant plustrace to public;