I need to see the queries that are being sent to Oracle to execute them. Can someone give me specific detailed instructions on how to do this ?
The following query may give you the list of running SQL ( SQL_ID ) from Active Sessions: select inst_id, program, module, SQL_ID, machine from gv$session where type!=
If you want to see the queries from a specific user, you can use this (assuming you have privileges to query v$session
and v$sqlarea
(usually through SELECT_CATALOG_ROLE
)
SELECT sess.sid,
sess.username,
sqla.optimizer_mode,
sqla.hash_value,
sqla.address,
sqla.cpu_time,
sqla.elapsed_time,
sqla.sql_text
FROM v$sqlarea sqla, v$session sess
WHERE sess.sql_hash_value = sqla.hash_value
AND sess.sql_address = sqla.address
AND sess.username = 'SCOTT'
Replace SCOTT with the appropriate username in your system
Output:
544 SCOTT ALL_ROWS 2004330732 07000001064088E8 89391 131836 SELECT sess.sid, sess.username,
sqla.optimizer_mode, sqla.h
ash_value, sqla.address, s
qla.cpu_time, sqla.elapsed_time,
sqla.sql_text FROM v$sqlarea sq
la, v$session sess WHERE sess.sql_hash_
value = sqla.hash_value AND sess.sql_
address = sqla.address AND sess.usern
ame = 'SCOTT'
This query will show queries that are currently running:
select sql_text from v$sqlarea where users_executing > 0;
See documentation of V$SQLAREA
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With