Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting SQL Text from SCN or SQL ID

CharlovSep 14 2009 — edited Sep 14 2009
Hello,

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..
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 12 2009
Added on Sep 14 2009
2 comments
31,322 views