It is easy to find queries that have been running and that have executed previously during the session using TOAD in the Oracle database. But we may not always find such tools. Therefore, we may need to use queries for such situations.
We may use the following query to find which queries have executed previously or which queries are currently running in the existing sessions in the database.
With the following query, we can see the queries that are currently running, as well as the queries that have executed previously during the session.
1 2 3 4 5 6 7 8 9 10 11 12 | SELECT o.sid, o.sql_text, o.address, o.hash_value, o.user_name, o.inst_id, s.schemaname, o.sql_id FROM gv$open_cursor o, gv$session s WHERE o.saddr = s.saddr AND o.sid = s.sid AND o.inst_id = s.inst_id |