Wednesday, March 26, 2014

Dba Scripts

FINDING BIG TABLES BY BLOCKS-- in this example top 5

select t.owner, t.table_name, t.occupied_blocks
from
(select owner, table_name, blocks-empty_blocks occupied_blocks
from dba_tables
order by 3 desc nulls last) t
where rownum <=5

**************************************

owner    table_name,           t.occupied_blocks
SH          SALES                 918843
SYS       SOURCE$            135041
SH       COSTS                    82112
SYS      ARGUMENT$       58244
SYS       COL$                     56957


IDLE SESSIONS FOR MORE THAN  HOUR


select sid,serial#,username,trunc
(last_call_et/3600,2)||' hr'
last_call_et
from V$session where
last_call_et > 3600 and username is not null