Saturday, August 25, 2012

Querys for DBLOCKS & Size of the Table :

------------------------------:To find BDLOCKS :------------------------------------------

SELECT s.inst_id, NVL (s.username, 'Internal') "Database User", m.SID,
s.serial#, p.spid "DB OS Process", m.TYPE,
DECODE (m.lmode,
0, 'None',
1, 'Null',
2, 'Row Share',
3, 'Row Excl.',
4, 'Share',
5, 'S/Row Excl.',
6, 'Exclusive',
lmode, LTRIM (TO_CHAR (lmode, '990'))
) "Lock Type",
DECODE (m.request,
0, 'None',
1, 'Null',
2, 'Row Share',
3, 'Row Excl.',
4, 'Share',
5, 'S/Row Excl.',
6, 'Exclusive',
request, LTRIM (TO_CHAR (m.request, '990'))
) "Lock Request",
DECODE (command,
0, 'None',
DECODE (m.id2,
0, dusr.username || '.' || SUBSTR (dobj.NAME, 1, 30),
'Rollback Segment'
)
) "Object",
s.machine "Application Server", s.process "Apps OS process", m.ctime,
NVL (NVL (usr.description, s.action),
'Database Session'
) "Online User,Concurrent",
NVL (fnd.responsibility_name, s.module) "Responsibility,Module",
fnd.user_form_name "Form Name", SQL.sql_text "Statement"
FROM gv$session s,
gv$lock m,
gv$process p,
apps.fnd_form_sessions_v fnd,
apps.fnd_user usr,
gv$sqlarea SQL,
dba_users dusr,
SYS.obj$ dobj
WHERE m.id1 IN (SELECT il.id1
FROM gv$lock il
WHERE il.request <> 0)
AND m.SID = s.SID
AND s.paddr = p.addr
AND s.inst_id = p.inst_id
AND SQL.inst_id(+) = s.inst_id
AND SQL.address(+) = s.sql_address
AND SQL.hash_value(+) = s.sql_hash_value
AND s.username != 'SYS'
AND m.lmode != 4
AND fnd.audsid(+) = s.audsid
AND m.inst_id = s.inst_id
AND fnd.user_name = usr.user_name(+)
AND fnd.user_id = usr.user_id(+)
AND dobj.obj#(+) = DECODE (m.id2, 0, m.id1, 1)
AND dusr.user_id(+) = dobj.owner#
ORDER BY m.id1, m.request ASC, m.SID;
To know Particilar Table Size :
SQL> SELECT tbl.owner TABLE_OWNER,
tbl.TABLE_NAME ,
tbl.TABLESPACE_NAME,
ceil((BLOCKS*8192 / 1024/1024 ) - (NUM_ROWS*AVG_ROW_LEN/1024/1024)) "Data lower than HWM in MB"
FROM  DBA_TABLES tbl
where table_name like 'XX_EMF_ERROR_DETAILS'; 

-----------------------------------Temp Usage :-----------------------------------

SELECT   A.tablespace_name tablespace, D.mb_total,
         SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_used,
         D.mb_total - SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_free
FROM     v$sort_segment A,
         (
         SELECT   B.name, C.block_size, SUM (C.bytes) / 1024 / 1024 mb_total
         FROM     v$tablespace B, v$tempfile C
         WHERE    B.ts#= C.ts#
         GROUP BY B.name, C.block_size
         ) D
WHERE    A.tablespace_name = D.name
GROUP by A.tablespace_name, D.mb_total;

---------------------To know the Product  Version & Patchset level---------------------

select decode(nvl(a.APPLICATION_short_name,'Not Found'),
        'SQLAP','AP','SQLGL','GL','OFA','FA',
        'Not Found','id '||to_char(fpi.application_id),
        a.APPLICATION_short_name) apps,
        decode(fpi.status,'I','Installed','S','Shared',
               'N','Inactive',fpi.status) status,
        fpi.product_version,
        nvl(fpi.patch_level,'-- Not Available --') Patchset,
        to_char(fpi.last_update_date,'dd-Mon-RRRR') "Update Date"
from fnd_oracle_userid o, fnd_application a, fnd_product_installations fpi
where fpi.application_id = a.application_id(+)
  and fpi.oracle_id = o.oracle_id(+)
order by 1,2
/
APPS                                               STATUS    PRODUCT_VERSION                PATCHSET                       Update Date
-------------------------------------------------- --------- ------------------------------ ------------------------------ -----------------
AD                                                 Shared    12.0.0                         R12.AD.B.2                     05-Sep-2010

-------------------------To find Conc-req  Completion ------------------------

SELECT fcr.REQUEST_ID,fc.USER_CONCURRENT_PROGRAM_NAME,TO_CHAR(fcr.actual_start_date,'DD-MON HH24:MI:SS') actual_start_date,TO_CHAR(fcr.actual_completion_date,'DD-MON HH24:MI:SS') actual_completion_date,fcr.STATUS_CODE
FROM FND_CONCURRENT_REQUESTS fcr,
                FND_CONCURRENT_PROGRAMS_TL fc
WHERE fcr.phase_code='C'
                AND fc.concurrent_program_id=fcr.concurrent_program_id
                AND fc.USER_CONCURRENT_PROGRAM_NAME='&Conc-req_name' order by fcr.actual_start_date ;

-------------
TOP sqls :
-------------
set linesize 1000
set pagesize 1000
col sql for a50
SELECT sql,buffer_gets, executions
FROM (SELECT hash_value,address,substr(sql_text,1,40) sql,
            buffer_gets, executions, buffer_gets/executions "Gets/Exec"
      FROM V$SQLAREA
      WHERE buffer_gets > 100000 AND executions > 10
      ORDER BY buffer_gets DESC)
      WHERE rownum <= 5
/

No comments:

Post a Comment