Skip navigation.

Quick overview of the state of an Oracle database.

David Lozano Lucas's picture

One common problem: You are allocated to a new project and find that nothing is documented.
By running this script, you get four important points of information: Tablespace status, installed products and its versions, oracle parameters different to default and status of tables:

SET LINESIZE 1000
SET PAGESIZE 1000
spool report.txt
prompt You can leave this script copied at $ORACLE_HOME\rdbms\admin\
prompt - Remember to use also statspack o bstats depending on the Oracle version
prompt - Review alert.log
prompt
prompt
prompt TABLESPACE STATUS
Select t.tablespace_name  "Tablespace",  t.status "Estado",  
    ROUND(MAX(d.bytes)/1024/1024,2) "MB Tamaño",
    ROUND((MAX(d.bytes)/1024/1024) - 
    (SUM(decode(f.bytes, NULL,0, f.bytes))/1024/1024),2) "MB Usados",   
    ROUND(SUM(decode(f.bytes, NULL,0, f.bytes))/1024/1024,2) "MB Libres", 
    t.pct_increase "% incremento", 
    SUBSTR(d.file_name,1,80) "Fichero de datos"  
FROM DBA_FREE_SPACE f, DBA_DATA_FILES d,  DBA_TABLESPACES t  
WHERE t.tablespace_name = d.tablespace_name  AND 
    f.tablespace_name(+) = d.tablespace_name    
    AND f.file_id(+) = d.file_id GROUP BY t.tablespace_name,   
    d.file_name,   t.pct_increase, t.status ORDER BY 1,3 DESC;
prompt
prompt
prompt INSTALLED PRODUCTS AND ITS VERSION
select * from product_component_version;
prompt
prompt
prompt ORACLE PARAMETERS DIFFERENT TO DEFAULT
select name, value from v$parameter where isdefault = 'FALSE';
prompt
prompt
prompt STATUS OF TABLES
select OWNER,TABLE_NAME,PCT_FREE,PCT_USED,AVG_SPACE,PARTITIONED,LAST_ANALYZED from DBA_TABLES ORDER BY OWNER,AVG_SPACE;
spool off;
quit

Of course, you can modify it, add it to your monitoring scripts, or just run it on a regular basis as well.