Thursday, February 28, 2019

Database used Size and Free space

select round(sum(used.bytes) / 1024 / 1024/1024 ) || ' GB' "Database Size",
round(free.p / 1024 / 1024/1024) || ' GB' "Free space"
from (select bytes from v$datafile
      union all
      select bytes from v$tempfile
      union all
      select bytes from v$log) used, 
(select sum(bytes) as p from dba_free_space) free
group by free.p;

RMAN STATUS

SELECT OPERATION, STATUS, MBYTES_PROCESSED, START_TIME, END_TIME from V$RMAN_STATUS;

Check RMAN backup status complete

set pagesize 200
set linesize 200

select SESSION_KEY, INPUT_TYPE, STATUS,
to_char(START_TIME,'mm-dd-yyyy hh24:mi:ss') as RMAN_Bkup_start_time,
to_char(END_TIME,'mm-dd-yyyy hh24:mi:ss') as RMAN_Bkup_end_time,
elapsed_seconds/3600 Hours from V$RMAN_BACKUP_JOB_DETAILS

Large Table of Oracle Database

col owner for a15
col SEGMENT_NAME for a35
col SizeGB for 999,999,999 heading "Size GB"
set linesize 132
set pagesize 200
set feedback off
break on report
col fn new_value filename
compute sum of SizeGB on report
select '/home/oracle/scripts/out/large_tables_report_'||to_char(sysdate, 'yyyymmdd')||'.log' as fn from dual;
spool &filename
select owner,segment_type,segment_name,bytes/1024/1024/1024 SizeGB
from dba_segments
where segment_type='TABLE' and
bytes/1024/1024/1024 > 1
order by 1,4 desc
/
spool off
set feedback on
exit

Large Index Of Table in Oracle

col owner for a15
col SEGMENT_NAME for a35
col SizeGB for 999,999,999 heading "Size GB"
set linesize 132
set pagesize 200
set feedback off
break on report
col fn new_value filename
compute sum of SizeGB on report
select '/home/oracle/scripts/out/large_tables_report_'||to_char(sysdate, 'yyyymmdd')||'.log' as fn from dual;
spool &filename
select owner,segment_type,segment_name,bytes/1024/1024/1024 SizeGB
from dba_segments
where segment_type='INDEX' and
bytes/1024/1024/1024 > 1
order by 1,4 desc
/
spool off
set feedback on
exit