語法:
explain plan for + 目標(biāo)SQL
select * from table(dbms_xplan.display);
創(chuàng)新互聯(lián)建站是專業(yè)的禹王臺網(wǎng)站建設(shè)公司,禹王臺接單;提供成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站、成都外貿(mào)網(wǎng)站建設(shè)公司,網(wǎng)頁設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行禹王臺網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來合作!
eg:
SQL> explain plan for select empno,ename,dname from scott.emp,scott.dept where emp.deptno=dept.deptno;
Explained.
SQL> set linesize 800
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------------------
Plan hash value: 844388907
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 14 | 364 | 6 (17)| 00:00:01 |
| 1 | MERGE JOIN | | 14 | 364 | 6 (17)| 00:00:01 |
| 2 | TABLE ACCESS BY INDEX ROWID| DEPT | 4 | 52 | 2 (0)| 00:00:01 |
| 3 | INDEX FULL SCAN | PK_DEPT | 4 | | 1 (0)| 00:00:01 |
|* 4 | SORT JOIN | | 14 | 182 | 4 (25)| 00:00:01 |
| 5 | TABLE ACCESS FULL | EMP | 14 | 182 | 3 (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
4 - access("EMP"."DEPTNO"="DEPT"."DEPTNO")
filter("EMP"."DEPTNO"="DEPT"."DEPTNO")
18 rows selected.
Oracle10g\11g中,如果我們對目標(biāo)SQL執(zhí)行explain plan命令,則oracle就將解析目標(biāo)SQL所產(chǎn)生的執(zhí)行計(jì)劃的具體執(zhí)行步驟寫入PLAN_TABLE$,隨后執(zhí)行select * from table(dbms_xplan.display),只是從PLAN_TABLE$中將這些具體執(zhí)行步驟以格式化的方式顯示出來。
PLAN_TABLE$是一個on commit preserve rows的global temporary table,所以這里Oracle可以做到各個session只能看到自己執(zhí)行的SQL所產(chǎn)生的執(zhí)行計(jì)劃,并且各個session往PLAN_TABLE$寫入執(zhí)行計(jì)劃的過程互不干擾。