-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdb_size.sql
30 lines (18 loc) · 1.08 KB
/
db_size.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
column dummy noprint
column pct_used format 999D9 heading "%|Used"
column name format a25 heading "Tablespace Name"
column bytes format 9G999G999G999G999 heading "Total Megs"
column used format 99G999G999G999 heading "Used"
column free format 999G999G999G999 heading "Free"
break on report
compute sum of bytes on report
compute sum of free on report
compute sum of used on report
select a.tablespace_name name, b.tablespace_name dummy,
sum(b.bytes)/count( distinct a.file_id||'.'||a.block_id ) /1024/1024 bytes,
sum(b.bytes)/count( distinct a.file_id||'.'||a.block_id )/1024/1024 - sum(a.bytes)/count( distinct b.file_id )/1024/1024 used,
sum(a.bytes)/count( distinct b.file_id ) /1024/1024 free,
100 * ( (sum(b.bytes)/count( distinct a.file_id||'.'||a.block_id )) - (sum(a.bytes)/count( distinct b.file_id ) )) / (sum(b.bytes)/count( distinct a.file_id||'.'||a.block_id )) pct_used
from sys.dba_free_space a, sys.dba_data_files b
where a.tablespace_name = b.tablespace_name
group by a.tablespace_name, b.tablespace_name;