ORACLE set autotrace in SQL*Plus

set autotrace off  
set autotrace on  
set autotrace traceonly  
 
set autotrace on explain  
set autotrace on statistics  
set autotrace on explain statistics  
 
set autotrace traceonly explain  
set autotrace traceonly statistics  
set autotrace traceonly explain statistics  
 
set autotrace off explain  
set autotrace off statistics  
set autotrace off explain statistics 
set autotrace off
set autotrace on
set autotrace traceonlysql

set autotrace on explain
set autotrace on statistics
set autotrace on explain statisticssession

set autotrace traceonly explain
set autotrace traceonly statistics
set autotrace traceonly explain statisticside

set autotrace off explain
set autotrace off statistics
set autotrace off explain statistics
 ip

设置autotrace容许显示DML语句的一些统计信息和/或查询计划。get

set autotrace on: 为语句显示统计信息和执行计划。it

set autotrace on explain: 只显示执行计划。io

set autotrace on statistics: 只显示统计信息。table

set autotrace traceonly: 显示执行计划和统计信息,可是打印查询结果。class

set autotrace off: 关闭autotracecli

若是用statistics选项打开autotrace,那么将显示下面的统计信息:

recursive calls
db block gets
consistent gets
physical reads
redo size
bytes sent via SQL*Net to client
bytes received via SQL*Net from client
SQL*Net roundtrips to/from client
sorts (memory)
sorts (disk)
前置条件

autotrace的执行计划特性须要建立一个plan_table表,能够用脚本

$ORACLE_HOME/rdbms/admin/utlxplan.sql 建立

统计特性须要用户具备v_$sesstat, v_$statname 和 v_$session表上的查询权限。

Oracle安装时附带的$ORACLE_HOME/sqlplus/admin/plustrce.sql 会安装plustrace角色,plustrace角色被授予了这些查询权限。若是plustrace角色被授予用户,那么他就能够具备打开autotrace的权限。或者你也能够把plustrace角色授予public。

相关文章
相关标签/搜索