-
Notifications
You must be signed in to change notification settings - Fork 36
/
df.sql
51 lines (49 loc) · 2.16 KB
/
df.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
-------------------------------------------------------------------------------------------
-- SCRIPT: DF.SQL
-- PURPOSE: Show Oracle tablespace free space in Unix df style
-- AUTHOR: Tanel Poder [ http://www.tanelpoder.com ]
-- DATE: 2003-05-01
-------------------------------------------------------------------------------------------
@inc/input_vars_init;
col "Tablespace"for a30
col "Used(%)" for a8
col "Free(%)" for a8
col "Used" for a52
select
rpad(t.tablespace_name,30,'..') as "Tablespace"
,t.type
,t.mb as "TotalMB"
,t.mb - nvl(f.mb, 0) as "UsedMB"
,nvl(f.mb, 0) as "FreeMB"
,to_char((1 - nvl(f.mb, 0) / decode(t.mb, 0, 1, t.mb))*100,'990.0')||'%' as "Used(%)"
,to_char(nvl(f.mb, 0)*100 / decode(t.mb, 0, 1, t.mb),'990.0')||'%' as "Free(%)"
,t.ext as "Ext"
,'|' || rpad(lpad('#'
,ceil((1 - nvl(f.mb, 0) / decode(t.mb, 0, 1, t.mb)) * 50)
,'#')
,50
,' ') || '|' as "Used"
from (select tablespace_name, trunc(sum(bytes) / 1048576) MB
from dba_free_space
group by tablespace_name
union all
select tablespace_name, trunc(sum(bytes_free) / 1048576) MB
from v$temp_space_header
group by tablespace_name) f
,(select tablespace_name
,'normal' type
,trunc(sum(bytes) / 1048576) MB
,max(autoextensible) ext
from dba_data_files
group by tablespace_name
union all
select tablespace_name
,'temp' type
,trunc(sum(bytes) / 1048576) MB
,max(autoextensible) ext
from dba_temp_files
group by tablespace_name) t
where t.tablespace_name = f.tablespace_name(+)
and t.tablespace_name like nvl(upper('&1'),'%')
order by t.tablespace_name;
@inc/input_vars_undef;