Purpose ======= To run the explain plan for a SQL statement stored in a file. Steps required to run the expsql script ======================================= 1. Copy the expsql.sql and expsql.bat to the default oracle directory. 2. The sql file passed as an argument for explain plan should end with a blank line and last character of the sql statemnet the should not be ; or /. Example to get the explain plan for statement 'select count(*) from emp;', the sql file should have following content. select count(*) from emp <> 3. To get explain plan for check.sql the argument to the expsql.sql should be passed as check and not as check.sql. expsql.bat ========== @ECHO OFF del expsql.$$$ ECHO explain plan set statement_id = 'explain_sql' for > expsql.$$$ COPY expsql.$$$ + %1.sql expsql.$$$ ECHO / >> expsql.$$$ expsql.sql ========== set feedback off set linesize 132 delete from plan_table where statement_id ='explain_sql' / host expsql.bat &1 @expsql.$$$ select substr(lpad(' ',2*(level-1))||operation,1,25) operation,substr(options,1,25) options ,substr(object_name,1,20) Object_name,position from plan_table start with id = 0 and statement_id = 'explain_sql' connect by prior id = parent_id and statement_id = 'explain_sql' / set feedback on Author ===== Dharminder Kumar from an idea by Peter Koletzke July 1999