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> 
相关推荐
吴声子夜歌1 小时前
PostgreSQL——索引
数据库·postgresql·oracle
一个有梦有戏的人10 小时前
软考架构师:数据库的范式
数据库·oracle
liulanba2 天前
Redis 缓存问题详解及解决方案
redis·缓存·oracle
小蜗的房子2 天前
Red Hat Enterprise Linux 7.9安装Oracle 11.2.0.4单实例数据库-图文详解
linux·运维·服务器·数据库·sql·oracle·数据库架构
就叫飞六吧2 天前
麻溜启动Oracle实例demo
数据库·oracle
小任今晚几点睡2 天前
MySQL基础知识总结
数据库·mysql·oracle
山茶花开时。3 天前
[Oracle] ADD_MONTHS()函数
数据库·oracle
小毛驴8503 天前
Oracle 的 exp(传统导出工具)和 expdp(Data Pump 导出工具)是两种命令对比
数据库·oracle
小蜗的房子4 天前
Linux-Redhat9.5图形化安装Oracle19.25单实例详细步骤
oracle
Runing_WoNiu4 天前
Mysql与Ooracle 索引失效场景对比
数据库·mysql·oracle