Determining SQL statements currently being executed
In addition to determine session information, the Oracle data dictionary tables can also be used to determine the current SQL statements being executed. James Koopmann has authored several articles on Database Journal regarding monitoring SQL statements. I strongly recommend reading his article. Below are some examples of extracting the SQL statements currently executed on an instance
SELECT hash_value,
sql_text
FROM v$sqlarea
WHERE users_executing > 0;
sesion.username,
optimizer_mode,
hash_value,
address,
cpu_time,
elapsed_time,
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;
SELECT u.sid,
substr(u.username,1,12) user_name,
s.sql_text
FROM v$sql s,
v$session u
WHERE s.hash_value = u.sql_hash_value
and sql_text not like '%from v$sql s, v$session u%'
ORDER BY u.sid;
Labels: Oracle
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home