1. Create the plan table
SQLPLUS> @${ORACLE_HOME}/rdbms/admin/utlxplan.sql
2. Delete old plan from the table and run explain plan.
Replace 'select * from v$database' with the actuall sql statement you want explain plan for.
set lin 180
set pages 0
set feedback on
set echo off
delete from plan_table
where STATEMENT_ID = 'p1'
/
EXPLAIN PLAN SET STATEMENT_ID = 'p1' FOR
select * from v$database
/
SELECT LPAD(' ',2*(LEVEL-1))||operation||' '||options
||' '||object_name
||' '||DECODE(id, 0, 'Cost = '||position) "Query Plan"
FROM plan_table
START WITH id = 0 AND statement_id = 'p1'
CONNECT BY PRIOR id = parent_id AND statement_id ='p1'
/
|