There are many ways to view execution plans. I will introduce them one by one in my blog in the future. This article describes the first method. You can use the explain plan command to view the execution plan.
1. log on to the database with an hr user
[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,201 1, Oracle. All rights reserved.
Connected:
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. Use the explain plan command
HR @ ENMOEDU> explain plan for select salary from employees where first_name like 'pat ';
Explained.
3. view the execution plan
HR @ ENMOEDU> select * from table (dbms_xplan.display );
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------
Plan hash value: 3033625502
Bytes -------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (% CPU) | Time |
Bytes -------------------------------------------------------------------------------------------
| 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 |
Bytes -------------------------------------------------------------------------------------------
Predicate Information (identified by operation id ):
---------------------------------------------------
2-access ("FIRST_NAME" = 'pat ')
Filter ("FIRST_NAME" = 'pat ')
15 rows selected.
Now, the execution plan is successfully viewed.