Home » RDBMS Server » Performance Tuning » check last statement executed
check last statement executed [message #203419] Wed, 15 November 2006 01:59 Go to next message
reena_ch30
Messages: 100
Registered: December 2005
Senior Member
Hi,

How can i check the last statemnet executed in v$sql/v$sqlarea?

Thanks
reena
Re: check last statement executed [message #203567 is a reply to message #203419] Wed, 15 November 2006 09:50 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10708
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
Please rephrase.
Last statment you executed or last statement executed by 'others'?
Re: check last statement executed [message #203637 is a reply to message #203419] Wed, 15 November 2006 22:22 Go to previous messageGo to next message
reena_ch30
Messages: 100
Registered: December 2005
Senior Member
Both
Re: check last statement executed [message #203660 is a reply to message #203637] Thu, 16 November 2006 00:11 Go to previous messageGo to next message
Mohammad Taj
Messages: 2412
Registered: September 2006
Location: Dubai, UAE
Senior Member

hi reena.

you can you v$session or v$sqlarea to find out last executed sql statement.

for last executed statement on every schema ( active session).

select sa.sql_text,ss.username
from v$session ss, v$sqlarea sa
where sa.hash_value = ss.prev_hash_value
**********
SQL> /

SQL_TEXT
--------------------------------------------------------------------------------

USERNAME
--------------------
DELETE FROM T
HR

GRANT SELECT ON T TO
HR

SELECT COUNT(*) FROM HR.T
SCOTT


SQL_TEXT
--------------------------------------------------------------------------------

USERNAME
--------------------
select sa.sql_text,ss.username from v$session ss, v$sqlarea sa where sa.hash_val

ue = ss.prev_hash_value
SYS


SQL_TEXT = First thousand characters of the SQL text for the current cursor

USERNAME = Oracle username

HASH_VALUE = Hash value of the parent statement in the library cache

PREV_HASH_VALUE = Used with SQL_HASH_VALUE to identify the last SQL statement executed

SQL_HASH_VALUE = Used with SQL_ADDRESS to identify the SQL statement that is currently being executed


Note : used sql_hash_value for currently executed statement;


hope this helps
Mohammad Taj.
Re: check last statement executed [message #203772 is a reply to message #203419] Thu, 16 November 2006 04:42 Go to previous messageGo to next message
reena_ch30
Messages: 100
Registered: December 2005
Senior Member
Please give me the query.

Thanks
Reena
Re: check last statement executed [message #203795 is a reply to message #203772] Thu, 16 November 2006 06:05 Go to previous message
Mohammad Taj
Messages: 2412
Registered: September 2006
Location: Dubai, UAE
Senior Member

hi reena

Please give me the query.


select sa.sql_text,ss.username
from v$session ss, v$sqlarea sa
where sa.hash_value = ss.prev_hash_value



http://www.orafaq.com/forum/m/203795/93410/#msg_203795


Cool

regards
Taj

[Updated on: Thu, 16 November 2006 06:05]

Report message to a moderator

Previous Topic: flushing the buffer cache
Next Topic: Chained Fetch Ratio & Parse to Execute Ratio
Goto Forum:
  


Current Time: Sat Nov 30 06:07:16 CST 2024