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 traceonlyset autotrace on explain
set autotrace on statistics set autotrace on explain statisticsset autotrace traceonly explain
set autotrace traceonly statistics set autotrace traceonly explain statisticsset autotrace off explain
set autotrace off statistics set autotrace off explain statistics设置autotrace允许显示DML语句的一些统计信息和/或查询计划。
set autotrace on: 为语句显示统计信息和执行计划。
set autotrace on explain: 只显示执行计划。
set autotrace on statistics: 只显示统计信息。
set autotrace traceonly: 显示执行计划和统计信息,但是打印查询结果。
set autotrace off: 关闭autotrace
如果用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。