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 小时前
DDD 系列:实体和值对象详解
数据库·oracle·ddd·领域驱动设计
多巴胺梦想家1 天前
事务与并发控制:当多人同时操作数据库
服务器·数据库·oracle
ClouGence1 天前
Oracle 到 OceanBase 迁移方案横评:停机导出/导入 vs OMS vs CDC 工具
数据库·oracle
蓝胖的四次元口袋1 天前
JavaString知识梳理
数据库·oracle
七七powerful1 天前
Oracle 19C 19.27 季度补丁发布:RAC 环境升级全流程实战
数据库·oracle
2301_800256111 天前
第七章 空间存储与索引 知识点梳理-2
数据库·sql·oracle
山峰哥2 天前
数据库工程与索引策略实战指南‌
服务器·数据库·sql·oracle·深度优先
神道君天下2 天前
填充与积累:积分与面积的可视化
数据库·oracle
何中应2 天前
主流 OpenJDK 发行版下载安装
java·oracle·jdk·openjdk