AUTOTRACE

1.sqlplus
設置參數 set atuotrace on
SET AUTOTRACE OFF            --No AUTOTRACE report is generated. This is the default. 
SET AUTOTRACE ON EXPLAIN     --The AUTOTRACE report shows only the optimizer execution path. 
SET AUTOTRACE ON STATISTICS  --The AUTOTRACE report shows only the SQL statement execution statistics. 
SET AUTOTRACE ON             --The AUTOTRACE report includes both the optimizer execution path and the SQL statement execution statistics. 
SET AUTOTRACE TRACEONLY      --Like SET AUTOTRACE ON, but suppresses the printing of the user's query output, if any. If STATISTICS is enabled, query data is still fetched, but not printed. 

而後執行語句
在語句的結果後面會有執行計劃。
2.sqlplus
使用DBMS_XPLAN包。
詳盡信息見10g官方文檔B19306_01\B19306_01\appdev.102\b14258\d_xplan.htm#sthref9740
例子:
示例:
SQL> EXPLAIN PLAN FOR
  2  SELECT * FROM test;

已解釋。

SQL> SET LINESIZE 130
SQL> SET PAGESIZE 0
SQL> SELECT * FROM table(DBMS_XPLAN.DISPLAY);
Plan hash value: 1357081020

--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |    16 |    48 |     3   (0)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| TEST |    16 |    48 |     3   (0)| 00:00:01 |
--------------------------------------------------------------------------

已選擇8行。

3.plsql developer
  在sql window 窗口寫sql,而後按F5,則會出現執行計劃窗口。
相關文章
相關標籤/搜索