set autotrace on 报cannot set autotrace错误
2015-09-29 14:42
330 查看
今天想看一下scott用户下的sql的执行计划的,可是在PL/SQL的command窗口中输入set autotrace on时,却报Cannot SET AUTOTRACE的错误,后来查阅了很多网上的说法,最终得到下面的一些经验。
首先,我去sys用户中查看了plustrace角色,发现并不存在;
然后问题就很明确了,创建出来plustrace这个角色,并赋给scott用户就好了,具体的步骤如下:
1、登陆sys用户,并执行utlxplan.sql脚本,创建plan表(以下路径为我本机的路径);
SQL> @D:\app\zl\product\11.2.0\dbhome_1\RDBMS\ADMIN\utlxplan.sql
Table created
2、还是在sys用户下,执行plustrce.sql脚本,数据库启用autotrace功能的安装脚本,主要是创建plustrace角色,并且授权 ,拥有plustrace最主要的目的是为了访问下面几个VIEW :v_$sesstat;v_$statname;v_$mystat;
SQL> @D:\app\zl\product\11.2.0\dbhome_1\sqlplus\admin\plustrce.sql
drop role plustrace;
drop role plustrace
ORA-01919: 角色 'PLUSTRACE' 不存在
create role plustrace;
Role created
grant select on v_$sesstat to plustrace;
Grant succeeded
grant select on v_$statname to plustrace;
Grant succeeded
grant select on v_$mystat to plustrace;
Grant succeeded
grant plustrace to dba with admin option;
Grant succeeded
set echo off
3、将角色plustrace赋予scott用户;
SQL> grant plustrace to scott;
Grant succeeded
在做完上述操作后,我去scott用户试了一下,发现还是报错Cannot SET AUTOTRACE,一下子完全不知道问题出在哪里了。
后来我又查阅了很多文章,发现有说set autotrace on这个命令必须在sql*plus中运行,在PL/SQL中会报错;
试了一下,果然是这样,必须要在sql*plus中运行才有效;
首先,我去sys用户中查看了plustrace角色,发现并不存在;
然后问题就很明确了,创建出来plustrace这个角色,并赋给scott用户就好了,具体的步骤如下:
1、登陆sys用户,并执行utlxplan.sql脚本,创建plan表(以下路径为我本机的路径);
SQL> @D:\app\zl\product\11.2.0\dbhome_1\RDBMS\ADMIN\utlxplan.sql
Table created
2、还是在sys用户下,执行plustrce.sql脚本,数据库启用autotrace功能的安装脚本,主要是创建plustrace角色,并且授权 ,拥有plustrace最主要的目的是为了访问下面几个VIEW :v_$sesstat;v_$statname;v_$mystat;
SQL> @D:\app\zl\product\11.2.0\dbhome_1\sqlplus\admin\plustrce.sql
drop role plustrace;
drop role plustrace
ORA-01919: 角色 'PLUSTRACE' 不存在
create role plustrace;
Role created
grant select on v_$sesstat to plustrace;
Grant succeeded
grant select on v_$statname to plustrace;
Grant succeeded
grant select on v_$mystat to plustrace;
Grant succeeded
grant plustrace to dba with admin option;
Grant succeeded
set echo off
3、将角色plustrace赋予scott用户;
SQL> grant plustrace to scott;
Grant succeeded
在做完上述操作后,我去scott用户试了一下,发现还是报错Cannot SET AUTOTRACE,一下子完全不知道问题出在哪里了。
后来我又查阅了很多文章,发现有说set autotrace on这个命令必须在sql*plus中运行,在PL/SQL中会报错;
试了一下,果然是这样,必须要在sql*plus中运行才有效;
相关文章推荐
- 扩展PropertyPlaceholderConfigurer对prop文件中的属性加密
- Cuckoo Filter:设计与实现
- 需要安装 MongoDB,RabbitMQ,或者 MySQL?使用 Docker 来简化开发和测试
- java中的String作为参数引起的一些研究
- [IOS 开发] iOS 如何将日期字符串转成NSDate
- 需要安装 MongoDB,RabbitMQ,或者 MySQL?使用 Docker 来简化开发和测试
- SNMP v1 v2 v3
- B树、B+树、AVL树、红黑树
- Android清除本地数据缓存代码
- txt无法正常保存正文的解决办法
- [PHP-Debug] 使用 php -l 调试 PHP 错误遇到的坑
- [置顶] 我的Android进阶之旅------>Android解决异常: startRecording() called on an uninitialized AudioRecord.
- 四个PHP非常实用的功能
- CooradicatoarLayout 介绍
- Objective-C---5---字典,集合
- 【LeetCode】136 & 137 & 260 - Single Number I & II &III
- python中的enumerate
- git push 时遇到的问题
- 利用JDBC根据表结构生成ModelClass
- 重写和重载的区别