How to find which SQL is executed by a process

Reading Time: < 1 minute

If you are looking for the last SQL query ran by a specific process, try this: 

 
select substr(sa.sql_text,1,1000) txt
from v$process p, v$session s, v$sqlarea sa
where p.addr=s.paddr
and s.username is not null
and s.sql_address=sa.address(+)
and s.sql_hash_value=sa.hash_value(+)
and spid=&SPID;
Reading Time: < 1 minute

If you are looking for the last SQL query ran by a specific process, try this: 

 
select substr(sa.sql_text,1,1000) txt
from v$process p, v$session s, v$sqlarea sa
where p.addr=s.paddr
and s.username is not null
and s.sql_address=sa.address(+)
and s.sql_hash_value=sa.hash_value(+)
and spid=&SPID;

By Marc Olivier Meunier

Marc has spent the past few years putting oil on the fire of a hyper growth ad tech company. At Smartly.io he was in charge of scaling the support and its culture. At Eficode he is now leading an engineering team and running operations. He leads by example and puts a lot of emphasis on diversity and inclusion, constantly working to create a safe environment. A warm leader with a passion for memorable experiences and innovation.
Find Marc on Linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *