denrepo

OracleSQL tuning

Full SQL text for a SQL_ID

The complete statement, not the first 1,000 characters. Reads the cursor cache; an optional AWR lookup for aged-out statements is included, commented out because it needs the Diagnostics Pack.

Prompts for input

Not yet verified. How scripts are tested

ora-sql-text.sql
1CLEAR COLUMNS2SET LINESIZE 200 PAGESIZE 0 TRIMOUT ON TAB OFF VERIFY OFF LONG 1000000 LONGCHUNKSIZE 10000003 4SELECT sql_fulltext5FROM v$sql6WHERE sql_id = '&&sql_id'7  AND ROWNUM = 1;8 9-- If nothing came back and you have the Diagnostics Pack,10-- remove the -- from the next three lines:11-- SELECT sql_text12-- FROM dba_hist_sqltext13-- WHERE sql_id = '&&sql_id';14 15UNDEFINE sql_id16SET PAGESIZE 100

Save it as ora-sql-text.sql and run it with SQL> @ora-sql-text.

Open in denrepo

More Oracle scripts: SQL tuning