DB Admin: Database size in MBs

Database size in MB (Mega Bytes)

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/1048576, 2), '999,999.00') || ' MB');
dbms_output.put_line('Free: ' || TO_CHAR(Round(tfree_size_b/1048576, 2), '999,999.00') || ' MB');
dbms_output.put_line('Used: ' || TO_CHAR(Round(tused_size_b/1048576, 2), '999,999.00') || ' MB');
end;
/
SET SERVEROUTPUT OFF

Sample output:

April 16, 2014 В· Sanjay В· No Comments
Posted in: 1. DB Admin, 3. All Scripts

Leave a Reply

You must be logged in to post a comment.