I want to view the recently executed sql statements in the database ordered by recent ones first.
I am using both 9i and 10g database.
select sesion.sid, sesion.serial#, sesion.username, sesion.sql_id, sesion.sql_child_number, optimizer_mode, hash_value, address, sql_text from v$sqlarea sqlarea, v$session sesion where sesion.sql_hash_value = sqlarea.hash_value and sesion.sql_address = sqlarea.address and sesion.username is not null;
Jan-Marten Spit wrote:All this question should answered by OP, to give him clarify answer.
that shows only last SQL executed for sessions.
what about sessions that logged off?
what about the SQL that executed in SID 212 before the current SQL in that session?
the correct answer is v$sql.last_active for oracle 10 and higher, below that it can't be done with a SELECT.