-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsfree.sql
36 lines (36 loc) · 1.35 KB
/
tsfree.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
SET PAGES 999
SET LINES 999
COL tablespace_name FORMAT A20
WITH my_ddf AS
(
SELECT file_id, tablespace_name, file_name,
DECODE (autoextensible,
'YES', GREATEST (BYTES, maxbytes),
BYTES
) mysize,
DECODE (autoextensible,
'YES', CASE
WHEN (maxbytes > BYTES)
THEN (maxbytes - BYTES)
ELSE 0
END,
0
) growth
FROM dba_data_files)
SELECT my_ddf.tablespace_name,
ROUND (SUM (my_ddf.mysize) / (1024 * 1024)) totsize,
ROUND (SUM (growth) / (1024 * 1024)) growth,
ROUND ((SUM (NVL (freebytes, 0))) / (1024 * 1024)) dfs,
ROUND ((SUM (NVL (freebytes, 0)) + SUM (growth)) / (1024 * 1024)
) totfree,
ROUND ( (SUM (NVL (freebytes, 0)) + SUM (growth))
/ SUM (my_ddf.mysize)
* 100
) perc
FROM my_ddf, (SELECT file_id, SUM (BYTES) freebytes
FROM dba_free_space
GROUP BY file_id) dfs
WHERE my_ddf.file_id = dfs.file_id(+)
AND my_ddf.tablespace_name NOT LIKE '%UNDOTB%'
GROUP BY my_ddf.tablespace_name
ORDER BY 6 DESC;