Monday, February 29, 2016

Getting explain plan for Oracle sql query in a spool file

Use the below syntax to get explain plan for your sql statement in a spool file.

SET PAGES 10000 LINES 10000
SET ARRAYSIZE 2000
SET TIMING ON
SET TERMOUT ON
SET TRIMSPOOL ON
SET TAB OFF
SET ECHO ON
SET TRIMSPOOL ON

SPOOL explain_plan.txt

EXPLAIN PLAN FOR
SELECT columns FROM table;
SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());

SPOOL OFF;
EXIT;

No comments:

Post a Comment