I have the following 2 scripts that show tablespace usage and record counts. I want to merge them into one ;
=======================================
CLEAR
SET HEAD ON
SET VERIFY OFF
SET PAGES 200
PROMPT
ACCEPT tablespace_name PROMPT 'Enter Value Tablespace (Return For all) : '
col tspace form a20 Heading "Tablespace"
col tot_ts_size form 99999999999999 Heading "Size (Mb)"
col free_ts_size form 99999999999999 Heading "Free (Mb)"
col ts_pct form 999 Heading "% Free"
col ts_pct1 form 999 Heading "% Used"
break on report
compute sum of tot_ts_size on report
compute sum of free_ts_size on report
select df.tablespace_name tspace,
df.bytes/(1024*1024) tot_ts_size,
sum(fs.bytes)/(1024*1024) free_ts_size,
round(sum(fs.bytes)*100/df.bytes) ts_pct,
round((df.bytes-sum(fs.bytes))*100/df.bytes) ts_pct1
from dba_free_space fs, (select tablespace_name, sum(bytes) bytes
from dba_data_files
group by tablespace_name ) df
where fs.tablespace_name = df.tablespace_name
and df.tablespace_name like UPPER('%&tablespace_name%')
group by df.tablespace_name, df.bytes
order by df.tablespace_name
/
quit
========================================
select tablespace_name,sum(num_rows) from dba_tables
group by tablespace_name
========================================
=======================================
CLEAR
SET HEAD ON
SET VERIFY OFF
SET PAGES 200
PROMPT
ACCEPT tablespace_name PROMPT 'Enter Value Tablespace (Return For all) : '
col tspace form a20 Heading "Tablespace"
col tot_ts_size form 99999999999999 Heading "Size (Mb)"
col free_ts_size form 99999999999999 Heading "Free (Mb)"
col ts_pct form 999 Heading "% Free"
col ts_pct1 form 999 Heading "% Used"
break on report
compute sum of tot_ts_size on report
compute sum of free_ts_size on report
select df.tablespace_name tspace,
df.bytes/(1024*1024) tot_ts_size,
sum(fs.bytes)/(1024*1024) free_ts_size,
round(sum(fs.bytes)*100/df.bytes) ts_pct,
round((df.bytes-sum(fs.bytes))*100/df.bytes) ts_pct1
from dba_free_space fs, (select tablespace_name, sum(bytes) bytes
from dba_data_files
group by tablespace_name ) df
where fs.tablespace_name = df.tablespace_name
and df.tablespace_name like UPPER('%&tablespace_name%')
group by df.tablespace_name, df.bytes
order by df.tablespace_name
/
quit
========================================
select tablespace_name,sum(num_rows) from dba_tables
group by tablespace_name
========================================