Philip Howe’s Oracle Blog

Just another WordPress.com weblog

Posts Tagged ‘oracle’

What SQL is currently running

Posted by philiphowe on February 2, 2021

set linesize 2000
column username format a20
column machine format a20
column stmt format a80

SELECT nvl(ses.username,'ORACLE PROC')||' ('||ses.sid||')' USERNAME,
       SID,   
       MACHINE, 
       REPLACE(SQL.SQL_TEXT,CHR(10),'') STMT, 
      ltrim(to_char(floor(SES.LAST_CALL_ET/3600), '09')) || ':'
       || ltrim(to_char(floor(mod(SES.LAST_CALL_ET, 3600)/60), '09')) || ':'
       || ltrim(to_char(mod(SES.LAST_CALL_ET, 60), '09'))    RUNT 
  FROM V$SESSION SES,   
       V$SQLtext_with_newlines SQL 
 where SES.STATUS = 'ACTIVE'
   and SES.USERNAME is not null
   and SES.SQL_ADDRESS    = SQL.ADDRESS 
   and SES.SQL_HASH_VALUE = SQL.HASH_VALUE 
   and Ses.AUDSID <> userenv('SESSIONID') 
 order by runt desc, 1,sql.piece;
select x.sid
      ,x.serial#
      ,x.username
      ,x.sql_id
      ,x.sql_child_number
      ,optimizer_mode
      ,hash_value
      ,address
      ,sql_text
from   v$sqlarea sqlarea
      ,v$session x
where  x.sql_hash_value = sqlarea.hash_value
and    x.sql_address    = sqlarea.address
and    x.username       is not null;

select session.sid,
sql_text
from v$sqltext sqltext, v$session sesion
where sesion.sql_hash_value = sqltext.hash_value
and session.sql_address = sqltext.address
and session.username is not null
order by sqltext.piece;

Posted in Uncategorized | Tagged: , | Leave a Comment »

Undo corruption – Needs Recovery

Posted by philiphowe on June 11, 2009

I had a problem the other day with a missing UNDO tablespace.  I created a new one, however, the segments in the old tablespace were set to NEEDS RECOVERY.  Do not attempt this on a production database.  If you have the same problem, even on a test instance, you should contact Oracle Support.

DO NOT TRY THIS AT “HOME” : http://forums.oracle.com/forums/thread.jspa?threadID=698075

Posted in Database | Tagged: , , , , | Leave a Comment »