温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

【Oracle】SP2-0618: 无法找到会话标识符。启用检查 PLUSTRACE 角色

发布时间:2020-07-05 02:24:20 来源:网络 阅读:929 作者:yongjian1092 栏目:关系型数据库

一.错误描述



SQL> set autotrace on;
SP2-0618: 无法找到会话标识符。启用检查 PLUSTRACE 角色
SP2-0611: 启用 STATISTICS 报告时出错


二.解决办法



2.1 登录到sys用户,找到$ORACLE_HOME/SQLPLUS/ADMIN/plustrce.sql,执行之

> sqlplus / as sysdba
> @$ORACLE_HOME/SQLPLUS/ADMIN/PLUSTRCE.SQL

2.2 我们打开plustrce.sql看看里面是个什么鬼

--
-- Copyright (c) Oracle Corporation 1995, 2002.  All Rights Reserved.
--
-- NAME
--   plustrce.sql
--
-- DESCRIPTION
--   Creates a role with access to Dynamic Performance Tables
--   for the SQL*Plus SET AUTOTRACE ... STATISTICS command.
--   After this script has been run, each user requiring access to
--   the AUTOTRACE feature should be granted the PLUSTRACE role by
--   the DBA.
--
-- USAGE
--   sqlplus "sys/knl_test7 as sysdba" @plustrce
--
--   Catalog.sql must have been run before this file is run.
--   This file must be run while connected to a DBA schema.

set echo on

drop role plustrace;
create role plustrace;

grant select on v_$sesstat to plustrace;
grant select on v_$statname to plustrace;
grant select on v_$mystat to plustrace;
grant plustrace to dba with admin option;

set echo off

我们创建plustrace这个角色目的很明确了:

我们在SQL*PLUS上用SET AUTOTRACE ... STATISTICS的时候是通过plustrace这个角色来获取动态性能表信息的。当每一个用户要求使用该命令的时候会自动被DBA用户授予plustrace角色的权限。


参考:http://docs.oracle.com/cd/B10500_01/server.920/a96533/autotrac.htm


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI