REM REM DBAToolZ NOTE: REM This script was obtained from DBAToolZ.com REM It's configured to work with SQL Directory (SQLDIR). REM SQLDIR is a utility that allows easy organization and REM execution of SQL*Plus scripts using user-friendly menu. REM Visit DBAToolZ.com for more details and free SQL scripts. REM REM REM File: REM c_plan_script.sql REM REM UTIL TRACE REM REM Author: REM Vitaliy Mogilevskiy REM VMOGILEV REM (vit100gain@earthlink.net) REM REM Purpose: REM REM Creates execution plan for a given SQL script REM REM REM Usage: REM c_plan_script.sql REM REM Example: REM c_plan_script.sql script.sql REM REM REM History: REM 08-01-1998 VMOGILEV Created REM REM accept 1 prompt "Enter SQL file name to be explained:" explain plan set statement_id = '&1' for @&1 clear breaks clear columns clear computes set term on set feedback on set lines 132 set pages 900 -- col statement_id format a10 heading "SQL Name" col query_plan format a100 heading "Execution Plan" select rtrim(lpad(' ',2*level)|| rtrim(operation)||' - '|| rtrim(options)||' - '|| object_name) query_plan from plan_table where statement_id = '&1' connect by prior id = parent_id and statement_id = '&1' start with id = 0 order by statement_id / --truncate table plan_table;