Professional Documents
Culture Documents
CONCEPT
HISTORY
OK OK OK OK OK OK OK OK
--==============================================================================
-- GPI - Gunther Pipp rr
-- Desc: SQL Script to check the size of a table
-- thanks to Christian G rber for create alter database file statement
-- Date: 08.2013
--==============================================================================
prompt
prompt Parameter 1 = Tablespace Name => '&TABLESPACE'
prompt
select sum(freeable_mb)from (
select s.tablespace_name
, s.bytes / 1024 / 1024 as SIZE_MB
, (e.max_data_block_id * et.BLOCK_SIZE / 1024 / 1024) as max_used_mb
, (s.bytes - e.max_data_block_id * et.BLOCK_SIZE) / 1024 / 1024 as
freeable_mb
, s.file_id
, '..'||substr(s.file_name,length(s.file_name)-20,20) file_name
from dba_data_files s
, (select file_id
, max(block_id + blocks) + 1 max_data_block_id
, tablespace_name
from dba_extents
where tablespace_name like upper('&TABLESPACE.')
group by file_id,tablespace_name) e
, dba_tablespaces et
where s.FILE_ID = e.file_id
and s.TABLESPACE_NAME = et.TABLESPACE_NAME
and e.TABLESPACE_NAME =et.TABLESPACE_NAME
and et.TABLESPACE_NAME like upper('&TABLESPACE.')
)
/