• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to find current SQL statement being executed by particular session in Oracle

by admin

To find the current SQL statement being executed by particular session in Oracle, Query V$SQLAREA and V$SESSION views.

Here is the query to report the current SQL statement being executed by a session:

select substr(v2.sid,1,5)       "SID"
      ,substr(v2.username,1,8)  "Username"
      ,substr(program,1,10)     "Program"
,sql_text
 from
    sys.v_$sqlarea v1,
    sys.v_$session v2
  where
     v1.address= v2.sql_address and
     v1.hash_value = v2.sql_hash_value;

The above query will return the following for example:

SID   Username Program  SQL_TEXT
---   -------- -------  -----------------------------------
12    SCOTT    sqlplus  insert into ken values(1000)

Filed Under: oracle

Some more articles you might also be interested in …

  1. Oracle Data Guard 12c – Creating a Physical Standby from Primary
  2. Add Disk to ASM Disk Group using asmca
  3. How to check which options or features are used in the Oracle database
  4. DNS and DHCP Setup Example for Oracle Grid Infrastructure GNS
  5. How to Change SYS and SYSTEM Passwords in Oracle Database
  6. How to recreate the spfile for RAC instances where the spfile is stored in ASM
  7. Oracle Interview Questions : Recovery catalog for RMAN backup
  8. Beginners Guide to Sequences in Oracle
  9. What are the implications of rebuilding indexes in Oracle Database
  10. How To Create Device Alias For ASM Disks Using mknod On Linux/Unix

You May Also Like

Primary Sidebar

Recent Posts

  • grpck command – Remove corrupt or duplicate entries in the /etc/group and /etc/gshadow files.
  • xxd command – Expressed in hexadecimal form
  • sesearch: command not found
  • macof: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright