Friday, July 5, 2013

How do I calculate the table space size in oracle

select   /* + rule */
        df.tablespace_name "tablespace",
         df.bytes / (1024 * 1024 * 1024) "size(gb)",
         sum (fs.bytes) / (1024 * 1024 * 1024) "free(gb)",
         nvl (
            round (
               sum (fs.bytes) * 100 / df.bytes
            ),
            1
         ) "%free",
         round (
            (  df.bytes
             - sum (fs.bytes)
            ) * 100 / df.bytes
         ) "%used"
    from dba_free_space fs,
         (select   tablespace_name, sum (bytes) bytes
              from dba_data_files
             where tablespace_name like 'ontd%'
          group by tablespace_name) df
   where fs.tablespace_name(+) = df.tablespace_name
group by df.tablespace_name, df.bytes
order by 3 desc

to find the which sql is executing by the concurrent program in a schema
run the below query first to get the sid and the program details.

select   q.concurrent_queue_name qname, f.user_name, a.request_id "req id",
         decode (a.parent_request_id, -1, null, a.parent_request_id) "parent",
         a.concurrent_program_id "prg id", a.phase_code, a.status_code,
         vs.inst_id, vs.sid, vs.serial# "serial#", vp.spid,
         b.os_process_id apprsid,
           (  nvl (a.actual_completion_date, sysdate)
            - a.actual_start_date
           )
         * 1440
               "time",
            c.concurrent_program_name
         || ' - '
         || c2.user_concurrent_program_name "program"
    from applsys.fnd_concurrent_requests a,
         applsys.fnd_concurrent_processes b,
         applsys.fnd_concurrent_queues q,
         applsys.fnd_concurrent_programs_tl c2,
         applsys.fnd_concurrent_programs c,
         applsys.fnd_user f,
         gv$session vs,
         gv$process vp
   where a.controlling_manager = b.concurrent_process_id
     and a.concurrent_program_id = c.concurrent_program_id
     and a.program_application_id = c.application_id
     and c2.concurrent_program_id = c.concurrent_program_id
     and f.user_name = :user_name
     and c2.application_id = c.application_id
     and a.phase_code in ('i', 'p', 'r', 't')
     and a.status_code in ('r')
     and a.requested_by = f.user_id
     and b.queue_application_id = q.application_id
     and b.concurrent_queue_id = q.concurrent_queue_id
     and vp.spid = a.oracle_process_id
     and vs.paddr(+) = vp.addr
     and vs.inst_id(+) = vp.inst_id
order by 12;

query to find which sql is executing in a session

select a.sid, a.serial#, b.sql_text
   from v$session a, v$sqlarea b
    where a.sql_address=b.address
     and a.sid = :sid

No comments:

Post a Comment