Blog dedicated to Oracle Applications (E-Business Suite) Technology; covers Apps Architecture, Administration and third party bolt-ons to Apps

Wednesday, December 3, 2008

Tablespace scripts

From Jonathan Lewis:
select ts.tablespace_name, 
to_char(sum(nvl(fs.bytes,0))/1048576, '99,999,990.99') as MB_FREE, 
count(*) as FRAGMENTS, 
to_char(max(nvl(fs.bytes,0))/1048576, '99,999,990.99') as BIGGEST_BIT 
from dba_free_space fs, dba_tablespaces ts 
where fs.tablespace_name(+) = ts.tablespace_name 
group by rollup (ts.tablespace_name);

From Metalink Note: 1019999.6

SET ECHO off
REM NAME: TFSTSNFO.SQL
REM USAGE:"@path/tfstsnfo"
REM ------------------------------------------------------------------------
REM REQUIREMENTS:
REM SELECT on DBA_DATA_FILES, DBA_FREE_SPACE
REM ------------------------------------------------------------------------
REM PURPOSE:
REM Produces a brief report showing the filenames, free space,
REM size and status of all tablespaces in the database.
REM ------------------------------------------------------------------------
REM DISCLAIMER:
REM This script is provided for educational purposes only. It is NOT
REM supported by Oracle World Wide Technical Support.
REM The script has been tested and appears to work as intended.
REM You should always run new scripts on a test instance initially.
REM ------------------------------------------------------------------------
REM Main text of script follows:

set echo off
break on table_space on free
column free format 999,999,999,990
column bytes format 999,999,999,990
set pagesize 66
set lines 100
spool tblsp.out
select substr(df.tablespace_name,1,15) table_space,
sum(fs.bytes) free,
substr(df.file_name,1,35) Name_of_File,
df.bytes,
substr(df.status,1,5) stat
from dba_data_files df ,dba_free_space fs
where df.tablespace_name = fs.tablespace_name
group by substr(df.tablespace_name,1,15),
substr(df.file_name,1,35),
df.bytes,substr(df.status,1,5)
/
spool off
set echo on

No comments: