Home » SQL & PL/SQL » SQL & PL/SQL » Retrieve sql history (oracle 11g)
Retrieve sql history [message #536996] Sun, 25 December 2011 18:28 Go to next message
sanrajar
Messages: 13
Registered: April 2005
Junior Member

select a.logon_time, dbms_lob.substr(b.sql_fulltext, 4000,1)
from gv$session a,gv$sqlarea b
where 1=1
and a.sql_id=b.sql_id
and a.username='H72728'-- my schema name used to login in toad
and a.logon_time between sysdate - 10 and sysdate
order by a.logon_time desc

I have been running few queries in the system and I forgot to save some of those sqls which I ran.
So instead of rewriting all those sqls again - I am hoping to see if sqls run by a user via TOAD is stored anywhere in Oracle.
If so - it might be easy for me to retrieve my sql (hence save lots of time).

The F8 key used in toad to retrieve historic sqls - is not working for me for some reason.

I am not sure if oracle stores any of this information - but if anyone has an idea of retrieving this information - appreciate if you can share the knowledge.

Thanks,
Sanrajar
Re: Retrieve sql history [message #536997 is a reply to message #536996] Sun, 25 December 2011 21:04 Go to previous message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
query DBA_HIST_SQLTEXT which may or may not contain what you desire
Previous Topic: Replicating records with Cartesian Join
Next Topic: bind and host variables
Goto Forum:
  


Current Time: Sun Apr 05 09:18:55 CDT 2026