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> 
相关推荐
努力也学不会java2 天前
【设计模式】抽象工厂模式
java·设计模式·oracle·抽象工厂模式
不想被吃掉氩3 天前
MySQL的事务特性和高可用架构
数据库·oracle
FL16238631293 天前
C#winform流程图工具箱源码支持画矩形箭头圆形菱形保存为图片
数据库·oracle
正在走向自律3 天前
Java连接电科金仓数据库(KingbaseES)实战指南
java·数据库·oracle·国产数据库·kingbase
Xxtaoaooo3 天前
OpenTenBase分布式HTAP实战:从Oracle迁移到云原生数据库的完整指南
云原生·oracle·tdsql·opentenbase·腾讯云数据库
西贝爱学习4 天前
数据库系统概论的第六版与第五版的区别
数据库·oracle
我是zxb4 天前
EasyExcel:快速读写Excel的工具类
数据库·oracle·excel
_苏沐4 天前
cte功能oracle与pg执行模式对比
数据库·oracle
Blossom.1185 天前
从“能写”到“能干活”:大模型工具调用(Function-Calling)的工程化落地指南
数据库·人工智能·python·深度学习·机器学习·计算机视觉·oracle
不秃的开发媛5 天前
Java连接池详解:从Oracle到TiDB的随缘之旅
java·oracle·tidb