I was just asked by a junior administrator, how to determine what SQL is currently executing against her database. While this may seem a trivial task for those in the industry for some time, I thought it a very good question. The below SQL will display currently executing SQL within an Oracle RDBMS.
1. Logon to SQL*PLUS with dba privileges.
2. Execute the following SQL block against the v$sql and v$session tables. NOTE: in a grid environment, use the gv$ views.
select sql_text from v$sql where sql_id in
(select sql_id from v$session where status=’ACTIVE’);
3. Displayed results show currently executing SQL blocks.
SQL> select sql_text from v$sql where sql_id in
2 (select sql_id from v$session where status=’ACTIVE’);
SQL_TEXT
——————————————————————————–
select sql_text from v$sql where sql_id in (select sql_id from v$session where s
tatus=’ACTIVE’)
Larry Catt, OCP