官方文档https://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_eight.htm#i1037226sql
set autotrace off表示关闭,是默认的(set autot off)bash
set autotrace on表示显示结果、执行计划、统计信息(set autot on)oracle
set autotrace on explain表示显示结果、执行计划(set autot on exp)server
set autotrace on statistics表示显示结果、统计信息(set autot on stat)htm
set autotrace traceonly表示显示执行计划、统计信息(set autuot trace)blog
set autotrace traceonly explain表示显示执行计划(set autot trace exp)排序
set autotrace traceonly statistics表示显示统计信息(set autot trace stat)资源
统计信息能够看到资源消耗量,如物理读、逻辑读、redo量、排序量等文档
autotrace简写为autotget
explain简写为exp
statistics简写为stat
traceonly简写为trace
用户要有建立PLAN_TABLE表和有PLUSTRACE角色,才行
好比给scott用户赋权限,用scott用户执行@$ORACLE_HOME/rdbms/admin/utlxplan.sql 来建立PLAN_TABLE表
而后用sys用户执行@$ORACLE_HOME/sqlplus/admin/plustrce.sql 来建立PLUSTRACE角色
而后GRANT PLUSTRACE TO scott便可
具体以下:
16:27:36 SCOTT@edw> set autotrace on SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled SP2-0611: Error enabling STATISTICS report 16:27:51 SCOTT@edw> @$ORACLE_HOME/rdbms/admin/utlxplan.sql Table created. Elapsed: 00:00:00.11 16:59:54 SCOTT@edw> conn / as sysdba; Connected. 17:00:22 SYS@edw> @$ORACLE_HOME/sqlplus/admin/plustrce.sql 17:00:32 SYS@edw> 17:00:32 SYS@edw> drop role plustrace; drop role plustrace * ERROR at line 1: ORA-01919: role 'PLUSTRACE' does not exist Elapsed: 00:00:00.01 17:00:32 SYS@edw> create role plustrace; Role created. Elapsed: 00:00:00.01 17:00:32 SYS@edw> 17:00:32 SYS@edw> grant select on v_$sesstat to plustrace; Grant succeeded. Elapsed: 00:00:00.01 17:00:32 SYS@edw> grant select on v_$statname to plustrace; Grant succeeded. Elapsed: 00:00:00.01 17:00:32 SYS@edw> grant select on v_$mystat to plustrace; Grant succeeded. Elapsed: 00:00:00.00 17:00:32 SYS@edw> grant plustrace to dba with admin option; Grant succeeded. Elapsed: 00:00:00.01 17:00:32 SYS@edw> 17:00:32 SYS@edw> set echo off Elapsed: 00:00:00.01 17:01:27 SYS@edw> GRANT PLUSTRACE TO scott; Grant succeeded. Elapsed: 00:00:00.00 17:01:47 SYS@edw>