查看执行计划的方法有很多种,笔者今后将在博客里一一为大家介绍。本文介绍的是第一种方法,利用explain plan命令来查看执行计划
查看执行计划的方法有很多种,笔者今后将在博客里一一为大家介绍。本文介绍的是第一种方法,利用explain plan命令来查看执行计划。
1.用hr用户登录数据库
[oracle@enmoedu ~]$ sqlplus hr/oracle@enmoedu
sql*plus: release 11.2.0.3.0 production on thu apr 10 00:11:00 2014
copyright (c) 1982, 2011, oracle. all rights reserved.
connected to:
oracle database 11g enterprise edition release 11.2.0.3.0 - production
with the partitioning, olap, data mining and real application testing options
hr@enmoedu >
2.使用explain plan命令
hr@enmoedu > explain plan for select salary from employees where first_name like 'pat';
explained.
3.查看执行计划
hr@enmoedu > select * from table(dbms_xplan.display);
plan_table_output
------------------------------------------------------------------------
plan hash value: 3033625502
-------------------------------------------------------------------------------------------
| id | operation | name | rows | bytes | cost (%cpu)| time |
-------------------------------------------------------------------------------------------
| 0 | select statement | | 1 | 11 | 2 (0)| 00:00:01 |
| 1 | table access by index rowid| employees | 1 | 11 | 2 (0)| 00:00:01 |
|* 2 | index skip scan | emp_name_ix | 1 | | 1 (0)| 00:00:01 |
-------------------------------------------------------------------------------------------
predicate information (identified by operation id):
---------------------------------------------------
2 - access("first_name"='pat')
filter("first_name"='pat')
15 rows selected.
至此,,执行计划查看成功。











