普通用户使用set autotrace
2016-11-21 17:27
316 查看
关于set autotrace
SET AUTOTRACE OFF ---------------- 不生成AUTOTRACE 报告,这是缺省模式SET AUTOTRACE ON EXPLAIN ------ AUTOTRACE只显示优化器执行路径报告
SET AUTOTRACE ON STATISTICS -- 只显示执行统计信息
SET AUTOTRACE ON ----------------- 包含执行计划和统计信息
SET AUTOTRACE TRACEONLY ------ 同set autotrace on,但是不显示查询输出
默认情况下,普通用户是没有set auotrace的权限的
SQL> conn test/oracleConnected.
SQL> set autotrace on;
SQL> select * from user_tables;
Error ORA-942 while gathering statistics
SP2-0612: Error generating AUTOTRACE report
no rows selected
SP2-0612: Error generating AUTOTRACE report
Execution Plan
----------------------------------------------------------
ERROR:
ORA-01039: insufficient privileges on underlying objects of the view
SP2-0612: Error generating AUTOTRACE EXPLAIN report
SP2-0612: Error generating AUTOTRACE STATISTICS report
1. 在sys用户下运行plustrce.sql创建plustrace角色
[oracle@centos6 admin]$ cd $ORACLE_HOME/sqlplus/admin[oracle@centos6 admin]$ ls
glogin.sql help libsqlplus.def plustrce.sql pupbld.sql
[oracle@centos6 admin]$ pwd
/u01/app/oracle/product/11.2.0/db_1/sqlplus/admin
[oracle@centos6 admin]$ cat plustrce.sql
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
SQL> @plustrce.sql SQL> SQL> drop role plustrace; drop role plustrace * ERROR at line 1: ORA-01919: role 'PLUSTRACE' does not exist SQL> create role plustrace; Role created. SQL> SQL> grant select on v_$sesstat to plustrace; Grant succeeded. SQL> grant select on v_$statname to plustrace; Grant succeeded. SQL> grant select on v_$mystat to plustrace; Grant succeeded. SQL> grant plustrace to dba with admin option; Grant succeeded. SQL> SQL> set echo off
2, 将plustrace角色赋给需要的用户
SQL> grant plustrace to test;Grant succeeded.也可以直接赋给public角色
3. 创建plan_table,用来存储sql语句分析的结果
[oracle@centos6 admin]$ cd $ORACLE_HOME/rdbms/admin[oracle@centos6 admin]$ ls utlxplan*
utlxplan.sql
[oracle@centos6 admin]$ cat utlxplan.sql
create table PLAN_TABLE (
statement_id varchar2(30),
plan_id number,
timestamp date,
remarks varchar2(4000),
operation varchar2(30),
options varchar2(255),
object_node varchar2(128),
object_owner varchar2(30),
object_name varchar2(30),
object_alias varchar2(65),
object_instance numeric,
object_type varchar2(30),
optimizer varchar2(255),
search_columns number,
id numeric,
parent_id numeric,
depth numeric,
position numeric,
cost numeric,
cardinality numeric,
bytes numeric,
other_tag varchar2(255),
partition_start varchar2(255),
partition_stop varchar2(255),
partition_id numeric,
other long,
distribution varchar2(30),
cpu_cost numeric,
io_cost numeric,
temp_space numeric,
access_predicates varchar2(4000),
filter_predicates varchar2(4000),
projection varchar2(4000),
time numeric,
qblock_name varchar2(30),
other_xml clob
);
SQL> conn test/oracle Connected. SQL> show user USER is "TEST" SQL> @utlxplan.sql Table created. SQL> set autotrace on SQL> select * from user_tables;
即可正常使用set autotrace
相关文章推荐
- Oracle 使用scott用户 set autotrace on报错 SP2-0618,SP2-0611
- Oracle 非dba用户 使用 set autotrace 功能
- Oracle 非dba用户 使用 set autotrace 功能
- set Autotrace的使用
- set Autotrace使用的问题与解决
- Scott 用户 set autotrace 后执行sql 报错
- ORACLE之autotrace使用
- set autotrace in SQL*Plus
- 添加普通用户使用sudo命令
- 注解的力量 -----Spring 2.5 JPA hibernate 使用方法的点滴整理(三):通过 @Autowired的使用来消除 set ,get方法。
- 使用sudo来赋予普通用户root的权限
- Linux普通用户使用libusb访问usb设备的方法
- oracle set autotrace
- 如何禁止普通用户使用企业管理器列出服务器上的数据库列表
- [Sql*Plus] Set up Explain Plan and Autotrace
- 通过 @Autowired的使用来消除 set ,get方法 ---- Spring · JPA ·hibernate 的使用方法
- oracle autotrace 使用说明
- 如何使用sudo来允许普通用户使用超级用户权限
- gentoo linux 普通用户不能使用alsa声卡的解决方法
- 使用sudo来赋予普通用户root的权限 推荐