ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

【ERROR】非DBA用户要使用autotrace功能,报错(SP2-0618:和SP2-0611:和ORA-01919)

2021-04-10 11:08:52  阅读:203  来源: 互联网

标签:01919 grant SP2 Grant role SQL 报错 plustrace


一、问题描述

     使用sqlplus时,连接到业务用户时,想查看某SQL的执行计划,报【SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled】和【SP2-0611: Error enabling STATISTICS report】,通过相关文档检索后得知原因是缺少plus trace ROLE的权限,解决思路:赋予用户plustrace 权限即可。 


二、操作过程

1.登录用户,打开autotrace功能时报错

[oracle@db2 ~]$ sqlplus / as sysdba


SQL*Plus: Release 11.2.0.4.0 Production on Mon Mar 21 09:29:29 2016


Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> conn ptpcpuser

Enter password:

Connected.


SQL> set autot on

SP2-0618: Cannot find the Session Identifier.  Check PLUSTRACE role is enabled  

SP2-0611: Error enabling STATISTICS report  


2.给用户赋予plustrace权限,报错【ORA-01919: role 'PLUSTRACE' does not exist】该角色不存在

SQL> conn / as sysdba

Connected.


SQL >grant plustrace to scott;

grant plustrace to scott

      *

ERROR at line 1:  

ORA-01919: role 'PLUSTRACE' does not exist  


3.安装plustrce包,建立plustrace角色,执行$ORACLE_HOME/sqlplus/admin/plustrce.sql包

SQL >conn / as sysdba

Connected.


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 >


4.给用户赋予plustrace权限成功

SQL> grant plustrace to ptpcpuser;


Grant succeeded.


5.连接该用户,并且打开autotrace成功

SQL> conn ptpcpuser

Enter password:

Connected.


SQL> set autot trace

SQL> select nvl(SUM(t.bean_count), 0)/100 from bean_record t WHERE t.invest_multip > 1 AND t.status = '2';


Execution Plan

----------------------------------------------------------

Plan hash value: 3322369200


--------------------------------------------------------------------------------

--


| Id  | Operation          | Name        | Rows  | Bytes | Cost (%CPU)| Time

 |


--------------------------------------------------------------------------------

--


|   0 | SELECT STATEMENT   |             |     1 |     9 | 77835   (1)| 00:15:35

 |


|   1 |  SORT AGGREGATE    |             |     1 |     9 |            |

 |


|*  2 |   TABLE ACCESS FULL| BEAN_RECORD |  4591K|    39M| 77835   (1)| 00:15:35

 |


--------------------------------------------------------------------------------

--


Predicate Information (identified by operation id):

---------------------------------------------------


   2 - filter("T"."INVEST_MULTIP">1 AND "T"."STATUS"='2')


Statistics

----------------------------------------------------------

          0  recursive calls

          0  db block gets

     313283  consistent gets

     313277  physical reads

          0  redo size

        549  bytes sent via SQL*Net to client

        520  bytes received via SQL*Net from client

          2  SQL*Net roundtrips to/from client

          0  sorts (memory)

          0  sorts (disk)

          1  rows processed


SQL>



三、总结

     此问题有两个知识点,(1)是用户缺少set autotrace的权限,(2)是数据库缺少角色plustrace。这个问题对DBA来讲不是什么难事,但是还是要注意权限的管理与回收。继续学习喽,下回见。


标签:01919,grant,SP2,Grant,role,SQL,报错,plustrace
来源: https://blog.51cto.com/lhrbest/2696679

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有