SET SERVEROUTPUT ON
declare
total_size_b number;
tfree_size_b number;
tused_size_b number;
begin
dbms_output.enable(100000);
select
Sum(bytes) into total_size_b
from
dba_data_files;
select
Sum(bytes) into tfree_size_b
from
dba_free_space;
select
Sum(bytes) into tused_size_b
from
dba_segments;
dbms_output.put_line('Total:' || TO_CHAR(Round(total_size_b/1024/1024/1024/1024, 2), '999,999.00') || ' TB');
dbms_output.put_line('Free: ' || TO_CHAR(Round(tfree_size_b/1024/1024/1024/1024, 2), '999,999.00') || ' TB');
dbms_output.put_line('Used: ' || TO_CHAR(Round(tused_size_b/1024/1024/1024/1024, 2), '999,999.00') || ' TB');
end;
/
SET SERVEROUTPUT OFF