The EXPLAIN PLAN statement enables you to examine the execution plan that the optimizer chose for a SQL statement.
When the statement is issued, the optimizer chooses an execution plan and then inserts data describing the plan into a database table.
Issue the EXPLAIN PLAN statement and then query the output table.
Executing EXPLAIN PLAN for a Single Statement
The basics of using the EXPLAIN PLAN statement are as follows:
Use the SQL script CATPLAN.SQL to create a sample output table called PLAN_TABLE in your schema.
Include the EXPLAIN PLAN FOR clause before the SQL statement.
After issuing the EXPLAIN PLAN statement, use a script or package provided by Oracle Database to display the most recent plan table output.
The execution order in EXPLAIN PLAN output begins with the line that is the furthest indented to the right. The next step is the parent of that line. If two lines are indented equally, then the top line is normally executed first.
To explain a SQL statement, use the EXPLAIN PLAN FOR clause immediately before the statement. For example: