oracle autotrace
--=======================
-- 启用 AUTOTRACE功能
--=======================
AUTOTRACE是一个SQL*Plus工具,用于跟踪SQL的执行计划,收集执行时所耗用资源的统计信息,是SQL优化工具之一,下面给出启用
AUTOTRACE 功能步骤。
一、创建基础表
运行$ORACLE_HOME/rdbms/admin/utlxplan脚本来创建plan_table
scott@ORCL> conn system/redhat --使用system帐户登陆
Connected.
system@ORCL> start $ORACLE_HOME/rdbms/admin/utlxplan --执行utlxplan脚本
Table created.
system@ORCL>
create public synonym plan_tablefor plan_table;
--为表plan_table创建公共同义词
Synonym created.
system@ORCL>
grant all on plan_tableto
public; --将同义词表plan_table授予给所有用户
Grant succeeded.
二、创建角色
运行$ORACLE_HOME/sqlplus/admin/plustrce.sql脚本
system@ORCL> conn
/ as sysdba --使用sysdba帐户登陆
onnected.
sys@ORCL> start $ORACLE_HOME/sqlplus/admin/plustrce.sql --执行创建角色的脚本
sys@ORCL>
sys@ORCL>
drop role plustrace;
drop
role plustrace
*
ERROR at line 1:
ORA-01919:role
'PLUSTRACE' doesnot exist
sys@ORCL>
create role plustrace;
Role created.
sys@ORCL>
sys@ORCL>
grant select on v_$sesstatto plustrace;
Grant succeeded.
sys@ORCL>
grant select on v_$statnameto plustrace;
Grant succeeded.
sys@ORCL>
grant select on v_$mystatto plustrace;
Grant succeeded.
sys@ORCL>
grant plustrace to dba
with admin option;
Grant succeeded.
三、角色的授予
在创建角色后,DBA首先被授予了该角色,且可以将角色授予其它组和用户。可以手工把plustrace授予给public,
则该数据库内所有的用户都将拥有plustrace角色的权限。也可以单独授予给某个组和用户
授予给所有用户
sys@ORCL>
grant plustrace to
public;
授予给单独用户
sys@ORCL>
grant plustrace to scott;
完成上述设置之后即可使用autotrace 功能
四、AUTOTRACE的几个选项
在sql提示符下输入set autot后将会给出设置autotrace的提示,如下
scott@ORCL>
set autot
Usage:
SET AUTOT[RACE] {OFF|
ON | TRACE[ONLY]} [EXP[LAIN]] [STAT[ISTICS]]
set autotrace off :缺省值,将不生成autotrace 报告
set autotrace on :包含执行计划和统计信息
set autotrace traceonly :等同于set autotrace on,但不显示查询输出的结果
set autotrace on explain :只显示优化器执行路径报告
set autotrace on statistics :只显示执行统计信息
scott@ORCL> set autotrace on;
scott@ORCL> select * from emp where ename='SCOTT';
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
Execution Plan
----------------------------------------------------------
Plan hash value: 3956160932
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 37 | 3 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| EMP | 1 | 37 | 3 (0)| 00:00:01 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("ENAME"='SCOTT')
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
8 consistent gets
0 physical reads
0 redo size
824 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
oracle autotrace的更多相关文章
- oracle autotrace使用
通过以下方法可以把Autotrace的权限授予Everyone, 如果你需要限制Autotrace权限,可以把对public的授权改为对特定user的授权. D:\oracle\ora92>sq ...
- Oracle的AUTOTRACE功能
ORACLE9i在使用autotrace之前,需要作一些初始设置: 1.用sys用户运行脚本utlxplan.sql创建PLAN_TABLE表 脚本目录:(UNIX:$ORACLE_HOME/rdbm ...
- Oracle性能优化--AUTOTRACE 操作
AUTOTRACE是一个SQL*Plus工具,用于跟踪SQL的执行计划,收集执行时所耗用资源的统计信息,是SQL优化工具之一,下面给出启用 AUTOTRACE 功能步骤. 一 .启用AUTOTRACE ...
- Oracle set autotrace 时提示:Cannot find the Session Identifier. Check PLUSTRACE role is enabled
SQL> set autotrace Usage: SET AUTOT[RACE] {OFF | ON | TRACE[ONLY]} [EXP[LAIN]] [STAT[ISTICS]] SQL ...
- Oracle运行set autotrace on报错SP2-0618、SP2-0611
SQL> set autotrace on SP2-0618: 无法找到会话标识符.启用检查 PLUSTRACE 角色 SP2-0611: 启用 STATISTICS 报告时出错 原因: PLU ...
- Oracle碎碎念~1
1. 设置SQL*Plus提示符 SQL> set sqlprompt "_user'@'_connect_identifier>" SYS@orcl> 为了对所 ...
- Oracle数据库该如何着手优化一个SQL
这是个终极问题,因为优化本身的复杂性实在是难以总结的,很多时候优化的方法并不是用到了什么高深莫测的技术,而只是一个思想意识层面的差异,而这些都很可能连带导致性能表现上的巨大差异. 所以有时候我们应该先 ...
- Oracle补全日志(Supplemental logging)
Oracle补全日志(Supplemental logging)特性因其作用的不同可分为以下几种:最小(Minimal),支持所有字段(all),支持主键(primary key),支持唯一键(uni ...
- 如何监控ORACLE索引使用与否
在数据库管理与维护中,我们总会遇到一个问题:我们创建的索引是否会被某些SQL语句使用呢?换个通俗表达方式:我创建的索引是否是未使用的索引(unused Indexes),是否有价值呢?如果创建的某个索 ...
随机推荐
- Morton Code
莫顿码 ,实现了一维与二维(或多维)的转换.它通过交叉存储两个数的位产生一个数,即莫顿码. 可以应用于为一个整数对产生一个唯一索引. 例如,对于坐标系中的坐标点使用莫顿编码生成的莫顿码,可以唯一索引对 ...
- 【Python】Django用户、认证、鉴权模块使用
此文是总结Django官方网站里面的Document的文章 User authentication in Django http://www.djangoproject.com/documentati ...
- 论#include
1.#include " "与#include <> #include " "表示预编译命令源程序在当前项目下寻找头文件,如果找不到,再到标准头文件 ...
- 使用dulilib DirectUI库(一)
1.在创建的窗口类里面 需要继承CWindowWnd.INotifyUI 对于CWindowWnd里面的方法: 实现;,重载virtualUINTGetClassStyle()const;返回窗口的风 ...
- Redis数据类型--List
Redis列表是简单的字符串列表,依照插入顺序排序. 你能够加入一个元素到列表的头部(左边)或者尾部(右边) LPUSH 命令插入一个新的元素到头部, RPUSH插入一个新元素到尾部. 当一个这两个操 ...
- [Functional Programming] Capture Side Effects in a Task / Async
We examine the data structure Task, see some constructors, familiar methods, and finally how it capt ...
- [AngularJS] Angular 1.3 ngAria - 2
This is an highlight about ngAira in Angular Document abou ngAira Where can use ngAria? Currently, n ...
- <The Art of Readable Code> 笔记一
第1章 代码应易理解 (Code should be easy to understand) 基本原则:好的代码,能够减少 “别人” 理解它的时间. “别人” 不仅指的是 “其它人”,也可能是 “以 ...
- llinux环境变量查看和修改
查看全局环境变量:env 查看所有环境变量:set 删除一个变量:unset [变量名] #只针对当前会话 设置一个变量:name=songjiankang export name #将这个变量提升为 ...
- 转:【微信小程序】实现锚点定位楼层跳跃的实例
微信小程序实现楼层锚点跳跃,点击不同的锚点进行位置跳跃: 利用:scroll-into-view 来实现: 效果图: wxml: <scroll-view class="cont ...