Problem solve Get help with specific problems with your technologies, process and projects.

Query for multiple Oracle processes and transactions

Here is a query that shows how long the an update statement has been running, how much rollback space it has used, and more.

Ever wanted a handy way to find out how long an UPDATE update statement has been running, how much rollback space it has used, etc? Or who are all the people connected to the database and exactly what are they doing right now? Here is a query that shows all. It has been successfully tested on all three releases of Oracle 8i.

set head on
set pages 55
set lines 250
column time format a7
column command format a16
break on username skip 1
accept username prompt 'Enter Username (ALL for all): '
select substr(s.username,1,18) username, s.sid, s.serial#,
substr(s.terminal,1,15) terminal,
       substr(s.program,1,15) program,
       decode(s.command, 0,'No Command', 1,'Create Table', 2,'Insert',
3,'Select', 6,'Update', 7,'Delete',
 9,'Create Index', 15,'Alter Table', 21,'Create View', 35,'Alter
Database', 39,'Create Tablespace', 
 41,'Drop Tablespace', 40,'Alter Tablespace', 62,'Analyze Table',
63,'Analyze Index', 23,'Validate Index', 
 53,'Drop User',
 s.command||': Other') command,
hh24:mi:ss')),1),0)||'"' time,
       t.log_io, t.phy_io, t.cr_get, t.cr_change,
       substr(,1,8) rbs_name,  r.rssize, r.extents, r.curext
from  v$session s, v$process p, v$transaction t, v$rollstat r, v$rollname n
where s.paddr = p.addr
and   s.taddr = t.addr (+)
and   t.xidusn = r.usn (+)
and   r.usn = n.usn (+)
and   s.username like decode(upper('&username'), 'ALL',s.username,
order by 1
clear breaks 

For More Information

  • Feedback: E-mail the editor with your thoughts about this tip.
  • More tips: Hundreds of free Oracle tips and scripts.
  • Tip contest: Have an Oracle tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize -- submit your tip today!
  • Ask the Experts: Our SQL, database design, Oracle, SQL Server, DB2, metadata, and data warehousing gurus are waiting to answer your toughest questions.
  • Forums: Ask your technical Oracle questions--or help out your peers by answering them--in our active forums.
  • Best Web Links: Oracle tips, tutorials, and scripts from around the Web.

Dig Deeper on Oracle and SQL

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.