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),是否有价值呢?如果创建的某个索 ...
随机推荐
- 每日一小练——Armstrong数
上得厅堂.下得厨房,写得代码,翻得围墙,欢迎来到睿不可挡的每日一小练! 题目:Armstrong数 内容: 在三位的正整数中,比如abc.有一些能够满足a^3+b^3+c^3=abc的条件,也就是说各 ...
- PHP接收跨域请求header 头设置
header("Access-Control-Allow-Origin: http://a.com"); // 允许a.com发起的跨域请求 //如果需要设置允许所有域名发起的跨域 ...
- 友元程序集(C# 和 Visual Basic)
友元程序集(C# 和 Visual Basic) Visual Studio 2013 “友元程序集”是一种能够访问其他程序集的 Friend (Visual Basic) 或 internal (C ...
- org.hibernate.MappingException: An association from the table order_intem_inf refers to a unmapped
执行一个HIbernate的演示样例时出现例如以下错误信息 Exception in thread "main" java.lang.ExceptionInInitializerE ...
- (剑指Offer)面试题49:把字符串转换为整数
题目: 将一个字符串转换成一个整数,要求不能使用字符串转换整数的库函数. 思路: 考虑+.-.空格.非数字字符,以及溢出问题 代码: #include <iostream> using n ...
- nginx的 CPU參数worker_processes和worker_cpu_affinity使用说明
Nginx默认没有开启利用多核CPU,我们能够通过添加worker_cpu_affinity配置參数来充分利用多核CPU.CPU是任务处理,计算最关键的资源,CPU核越多.性能就越好. worker_ ...
- hdu 2896 AC自动机模版题
题意:输出出现模式串的id,还是用end记录id就可以了. 本题有个关键点:“以上字符串中字符都是ASCII码可见字符(不包括回车).” -----也就说AC自动机的Trie树需要128个单词分支. ...
- Sublime key
-– BEGIN LICENSE -– TwitterInc 200 User License EA7E-890007 1D77F72E 390CDD93 4DCBA022 FAF60790 61AA ...
- 让zend studio 支持 redis函数自动提示
phpredis作者https://github.com/nicolasff/phpredis 写了文档https://github.com/ukko/phpredis-phpdoc上面提到了如何让e ...
- 转:【微信小程序】 微信小程序-拍照或选择图片并上传文件
调用拍照API:https://mp.weixin.qq.com/debug/wxadoc/dev/api/media-picture.html?t=20161222#wxchooseimageobj ...