set autotrace报错

报错:

复制代码
SQL> set autotrace traceonly
SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled
SP2-0611: Error enabling STATISTICS report

原因分析:

根据上面的错误提示"SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled"我们知道是****因为PLUSTRACE角色没有授权给该用户导致的****

解决办法:

重新创建PLUSTRACE用户

复制代码
SQL> conn / as sysdba
Connected.
SQL> select * from dba_role_privs where granted_role='SQL> conn / as sysdba
Connected.
SQL> select * from dba_role_privs where granted_role='PLUSTRACE';

no rows selected

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.

SQL> 
SQL> set echo off
SQL> ';

no rows selected

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.

SQL> 
SQL> set echo off
SQL> 

发现sys用户执行成功,但是scott用户执行还是失败

复制代码
SQL> conn / as sysdba
Connected.
SQL> set autotrace traceonly;
SQL> conn scott/oracle
Connected.
SQL> set autotrace traceonly;
SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled
SP2-061

将统计信息视图权限赋予scott

复制代码
grant select on v_$sesstat to SCOTT;
grant select on v_$statname to SCOTT;
grant select on v_$mystat to SCOTT;

再次执行成功

复制代码
SQL>  set autotrace traceonly;
SQL> 
相关推荐
小小不董3 小时前
Oracle OCP认证考试考点详解083系列09
linux·数据库·oracle·dba
怀君8 小时前
Flutter——数据库Drift开发详细教程(一)
数据库·flutter·oracle
liaokailin8 小时前
Spring AI 实战:第七章、Spring AI Advisor机制之记忆大师
人工智能·spring·oracle
试着9 小时前
【数据库】四种连表查询:内连接,外连接,左连接,右连接
数据库·mysql·oracle
betazhou9 小时前
基于windows安装MySQL8.0.40
windows·mysql·adb·oracle·mysql8
南風_入弦1 天前
优化01-统计信息
oracle·优化
一只栖枝1 天前
Oracle OCP证书有效期是三年?
数据库·oracle·开闭原则·ocp证书·考试流程
Blue.ztl1 天前
菜鸟之路Day29一一MySQL之DDL
数据库·mysql·oracle
小小不董1 天前
Oracle OCP认证考试考点详解083系列07
linux·数据库·oracle·dba