具体执行:
SQL> explain plan
2 for
3 select e.employee_id,e.last_name,d.department_name
4 from employees e, departments d
5 where e.department_id=d.department_id
6 and d.department_id=20;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 1475904561
----------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 62 | 2 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | 2 | 62 | 2 (0)| 00:00:01 |
| 2 | TABLE ACCESS BY INDEX ROWID | DEPARTMENTS | 1 | 16 | 1 (0)| 00:00:01 |
|* 3 | INDEX UNIQUE SCAN | DEPT_ID_PK | 1 | | 0 (0)| 00:00:01 |
| 4 | TABLE ACCESS BY INDEX ROWID BATCHED| EMPLOYEES | 2 | 30 | 1 (0)| 00:00:01 |
|* 5 | INDEX RANGE SCAN | EMP_DEPARTMENT_IX | 2 | | 0 (0)| 00:00:01 |
----------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("D"."DEPARTMENT_ID"=20)
5 - access("DEPARTMENT_ID"=20)
18 rows selected.
作者: 郑全 时间: 2020-3-11 00:44
第二种,通过PLSQL DEVELOPER 的按F5 提取执行计划,原理和第一种一样,并不真正执行SQL