代码改变世界

ORA-01919: role 'PLUSTRACE' does not exist

  AlfredZhao  阅读(1541)  评论(0编辑  收藏  举报

环境:Oracle 10g,11g.
现象:在一次迁移测试中,发现有这样的角色赋权会报错不存在:

SYS@orcl> grant PLUSTRACE to jingyu;
grant PLUSTRACE to jingyu
      *
ERROR at line 1:
ORA-01919: role 'PLUSTRACE' does not exist

查询发现这个角色是需要手工执行脚本创建,直接执行Oracle自带的SQL脚本@?/sqlplus/admin/plustrce.sql即可:

SYS@orcl> @?/sqlplus/admin/plustrce.sql
SYS@orcl> 
SYS@orcl> drop role plustrace;
drop role plustrace
          *
ERROR at line 1:
ORA-01919: role 'PLUSTRACE' does not exist


SYS@orcl> create role plustrace;

Role created.

SYS@orcl> 
SYS@orcl> grant select on v_$sesstat to plustrace;

Grant succeeded.

SYS@orcl> grant select on v_$statname to plustrace;

Grant succeeded.

SYS@orcl> grant select on v_$mystat to plustrace;

Grant succeeded.

SYS@orcl> grant plustrace to dba with admin option;

Grant succeeded.

SYS@orcl> 
SYS@orcl> set echo off
SYS@orcl> 

可以看到这个角色就是封装了对v_$sesstat,v_$statname,v_$mystat这几个视图的查询权限。

执行以后就可以直接赋予用户PLUSTRACE的角色了:

SYS@orcl> grant PLUSTRACE to jingyu;

Grant succeeded.
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2015-11-16 Oracle配置和使用闪回
点击右上角即可分享
微信分享提示