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。

相關文章
相關標籤/搜索