Layer 06

SQL in esecuzione su Oracle – Visualizzare le interrogazioni attive realtime

SELECT * FROM gv$session s, gv$process p , gv$open_cursor o where p.addr = s.paddr AND p.inst_id = s.inst_id and s.type != ‘BACKGROUND’ and o.saddr=s.saddr and o.sid=s.sid and o.hash_value=s.sql_hash_value   vi restituirà una serie di campi…. più o meno interessanti tra cui SQL_TEXT che è un excerpt dell’SQL lanciato, USERNAME che è l’utente di logon su Oracle, MACHINE che è il nome macchina da cui parte la query, PROGRAM che è il programma da cui è stata lanciata l’interrogazione e OSUSER che è l’utente di logon della macchina da cui è partito il tutto. Rielaborando quindi la query e facendo un po’ di ordine otterremo questo SQL:

SELECT s.machine, s.osuser, s.program, o.user_name, o.sql_text FROM gv$session s, gv$process p , gv$open_cursor o where p.addr = s.paddr AND p.inst_id = s.inst_id and s.type != ‘BACKGROUND’ and o.saddr=s.saddr and o.sid=s.sid and o.hash_value=s.sql_hash_value
Enjoy it!]]>