sqlplus的autotrace開關

官方文檔https://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_eight.htm#i1037226sql

image

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> 
相關文章
相關標籤/搜索