Home   Oracle SQL Scripts   Contact link Contact:  jack@dughaille.info

Description:
Display bytes in terms of KB, MB and GB

Example output:
SQL> select sum( bytes ) "SB" from dba_free_space; SB --------------- 35412312064 1 row selected. SQL> @bytes 35412312064 B Bytes K MB GB ------------------- ------------------------ ---------------- ------------ ----------- 35412312064 35,412,312,064 34,582,336 33,772 32.98 1 row selected.

Script:
prompt col "B" for 999999999999999999 col "Bytes" for 999,999,999,999,999,999 col "K" for 999,999,999,999 col "MB" for 999,999,999 col "GB" for 999,999.99 select to_number(replace('&1', ',', '' )) "B", to_number(replace('&1', ',', '' )) "Bytes", to_number(replace('&1', ',', '' ))/1024 "K", to_number(replace('&1', ',', '' ))/(1024*1024) "MB", to_number(replace('&1', ',', '' ))/(1024*1024*1024) "GB" from dual;