ORA-942 SP2-0611

环境:oracle 11.2.04


问题描述:
  在使用hr用户启用set autot trace时报错

set">HR@test>set autot trace; 
Error ORA-942 while gathering statistics 
SP2-0611: Error enabling STATISTICS report


问题原因:
  hr没有相关的权限。


处理办法:
  使用sys用户运行,plustrace.sql 创建相关角色,将角色权限赋予hr,即可。

SYS@test>@?/sqlplus/admin/plustrce.sql
SYS@test>
SYS@test>drop role plustrace;

Role dropped.

Elapsed: 00:00:02.55
SYS@test>create role plustrace;

Role created.

Elapsed: 00:00:00.05
SYS@test>
SYS@test>grant select on v_$sesstat to plustrace;

Grant succeeded.

Elapsed: 00:00:00.01
SYS@test>grant select on v_$statname to plustrace;

Grant succeeded.

Elapsed: 00:00:00.02
SYS@test>grant select on v_$mystat to plustrace;

Grant succeeded.

Elapsed: 00:00:00.02
SYS@test>grant plustrace to dba with admin option;

Grant succeeded.

Elapsed: 00:00:00.02
SYS@test>
SYS@test>set echo off
SYS@test>
SYS@test>grant plustrace to hr;

Grant succeeded.

Elapsed: 00:00:00.01
SYS@test>conn hr/hr
Connected.
HR@test>set autot trace
HR@test>
原文地址:https://www.cnblogs.com/afx1007/p/4065996.html