Getting SQL Text from SCN or SQL ID
CharlovSep 14 2009 — edited Sep 14 2009Hello,
I want to find out what was the query running on the DB fro the following SQL ID / SCN.
(SQL ID: c4dj7zctjwz0z, Query Duration=5 sec, SCN: 0x0001.af9c79f3):
I tried the below:
1- select sql_text from v$sql where sql_id = 'c4dj7zctjwz0z';
2-
SELECT
a.USERNAME, a.serial#, a.sid, a.STATUS, b.sql_text, b.SQL_ID
FROM V$SESSION a INNER JOIN V$SQLAREA b
ON a.SQL_ADDRESS= b.ADDRESS where B.SQL_ID = 'c4dj7zctjwz0z'
But it seems that the parameters have some mismatches, or maybe oracle does not store the SQL history for a long time (i think the scn/sqlid is for 1 or 2 days back)
Is it possible to retrieve the query from the SCN?
Thanks..