背景:Windows系统上装Oracle 11.2g数据库
问题:执行 set autotrace traceonly时报错,没有Plustrace角色
方法一:登录sys系统用户,创建plustrace角色,并赋予相应的权限(下面的权限),新建一个普通用户的会话,执行set autotrace traceonly就行
SQL> create role plustrace;
SQL> grant select on v_$sesstat to plustrace;
SQL> grant select on v_$statname to plustrace;
SQL> grant select on v_$mystat to plustrace;
SQL> grant plustrace to dba with admin option;
SQL> grant plustrace to dachui; /*将plustrace 角色赋给需要的用户,笔者的用户是dachui*/
方法二:Windows上的oracle的安装目录下有一个plustrce.sql文件(好像是每个人的文件名不一样,不过大致是在*/sqlplus/admin下)
笔者的安装的文件在下面目录下E:\app\Administrator\product\11.2.0\dbhome_2\sqlplus\admin
第一步:切换的Oracle的安装目录下,登录到sysdba系统用户
[C:\~]$ cd E:\app\Administrator\product\11.2.0\dbhome_2\sqlplus\admin
[E:\app\Administrator\product\11.2.0\dbhome_2\sqlplus\admin]$ sqlplus/nolog
SQL*Plus: Release 11.2.0.1.0 Production on 星期六 3月 30 23:33:35 2019
Copyright (c) 1982, 2010, Oracle. All rights reserved.
SQL> conn logon/as sysdba
输入口令:
已连接。
第二步:启动脚本
SQL> start plustrce.sql /*执行安装目录下的plustrce.sql文件*/
下面的sql是脚本启动时在终端上显示出的文件里的sql
SQL> drop role plustrace;
角色已删除。
SQL> create role plustrace;
角色已创建。
SQL> grant select on v_$sesstat to plustrace;
授权成功。
SQL> grant select on v_$statname to plustrace;
授权成功。
SQL> grant select on v_$mystat to plustrace;
授权成功。
SQL> grant plustrace to dba with admin option;
授权成功。
SQL>
SQL> set echo off
SQL>
第三步: 新建一个普通用户的会话,执行set autotrace traceonly就行
总结:方法一是将方法二中的文件内容提炼出来单独执行