PLUSTRACE角色

本人花费半年的时间总结的《Java面试指南》已拿腾讯等大厂offer,已开源在github ,欢迎star!

本文GitHub https://github.com/OUYANGSIHAI/JavaInterview 已收录,这是我花了6个月总结的一线大厂Java面试总结,本人已拿大厂offer,欢迎star

原文链接:blog.ouyangsihai.cn >> PLUSTRACE角色

使用示例数据库用户HR登陆需要打印执行计划等信息的时候,提示了错误,
PLUSTRACE角色
提示很清楚了,PLUSTRACE角色未赋给HR。

查询HR所有的角色,
PLUSTRACE角色
确实缺少PLUSTRACE角色,

通过oerr工具,可以进一步查看这个错误,
PLUSTRACE角色

AUTOTRACE Option in SQL*Plus (文档 ID 43214.1)中说明了要使用AUTOTRACE就必须有PLUSTRACE角色。

You can automatically get a report on the execution path used by the SQL optimizer and the statement execution statistics.  The report is generated after successful SQL DML (Data Manipulation Language - that is, SELECT, DELETE, UPDATE and INSERT) statements.  It is useful for monitoring and tuning the performance of these statements.

You can control the report by setting the AUTOTRACE system variable.  SET AUTOTRACE OFF           - No AUTOTRACE report is generated. This is the default.  SET AUTOTRACE ON EXPLAIN    - The AUTOTRACE report shows only the optimizer execution path.    SET AUTOTRACE ON STATISTICS - The AUTOTRACE report shows only the SQL statement execution statistics.  SET AUTOTRACE ON            - The AUTOTRACE report includes both the optimizer execution path and the SQL statement execution statistics.  SET AUTOTRACE TRACEONLY     - Like SET AUTOTRACE ON, but suppresses the printing of the user’s query output, if any.

To use this feature, you must have the PLUSTRACE role granted to you and a  PLAN_TABLE table created in your schema.  For more information on the PLUSTRACE role and PLAN_TABLE table, see the AUTOTRACE variable of the SET command in Chapter 6 of the SQL*Plus Guide.

解决方法:
1.这个脚本会创建PLUSTRACE角色,


$ORACLE_HOME/sqlplus/admin/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角色,将三张v_$的基表访问权限赋予PLUSTRACE角色,然后将PLUSTRACE授权DBA,并且有admin option属性。

2.执行脚本,
PLUSTRACE角色
PLUSTRACE角色

3.将PLUSTRACE授予HR,


SQL grant plustrace to hr;
Grant succeeded.

4.再次执行SET AUTOTTRACE,


SQL show user USER is "HR"
SQL set autot trace

如果您觉得此篇文章对您有帮助,欢迎关注微信公众号:bisal的个人杂货铺,您的支持是对我最大的鼓励!共同学习,共同进步:)

PLUSTRACE角色
本人花费半年的时间总结的《Java面试指南》已拿腾讯等大厂offer,已开源在github ,欢迎star!

本文GitHub https://github.com/OUYANGSIHAI/JavaInterview 已收录,这是我花了6个月总结的一线大厂Java面试总结,本人已拿大厂offer,欢迎star

原文链接:blog.ouyangsihai.cn >> PLUSTRACE角色


  转载请注明: 好好学java PLUSTRACE角色

 上一篇
SYS_CONTEXT函数返回IP地址的一些误解 SYS_CONTEXT函数返回IP地址的一些误解
上次分享中曾使用了SYS_CONTEXT函数获取ip地址,但返回值为空,当时认为其是返回ipv6的地址,所以为空,但其实这是错误的结论。虽然是一个小小的知识点,但从中可以看出Oracle对于这种内置函数的考虑非常周到,我们先看如下是返回空的
下一篇 
三种批量删除PLSQL写法效率的比对 三种批量删除PLSQL写法效率的比对
我们有一个重要的旧系统,最近夜维出现了一些问题,夜间执行5小时未完成,为了不影响业务,只能早上高峰期之前,DBA手工kill夜维进程。 这一个夜维程序采用了PLSQL写的存储过程,通过数据库job定时启动执行。存储过程我很少使用,借着这次机