14 October 2013

How to find the current SQL

Run following Sql,


SELECT S.USERNAME, S.SID, S.SERIAL#, SQL_TEXT FROM V$SESSION S, V$SQLTEXT_WITH_NEWLINES T WHERE S.SQL_ID IS NOT NULL AND S.SQL_ID = T.SQL_ID ORDER BY S.SID,T.PIECE;


or

SELECT sql_text FROM v$sql WHERE sql_id IN (SELECT sql_id FROM v$session);

No comments: