For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!
Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.
Just simply divide bytes by 1024/1024/1024:
SELECT a.TABLESPACE_NAME, Round(a.BYTES/1024/1024/1024,3) gigabytes_used, Round(b.BYTES/1024/1024/1024,3) gigabytes_free, Round(b.largest/1024/1024/1024,3), ROUND(((a.BYTES-b.BYTES)/a.BYTES)*100,2) percent_used FROM ( SELECT TABLESPACE_NAME, SUM(BYTES) BYTES FROM dba_data_files GROUP BY TABLESPACE_NAME ) a, ( SELECT TABLESPACE_NAME, SUM(BYTES) BYTES , MAX(BYTES) largest FROM dba_free_space GROUP BY TABLESPACE_NAME ) b WHERE a.TABLESPACE_NAME=b.TABLESPACE_NAME ORDER BY ((a.BYTES-b.BYTES)/a.BYTES) DESC;
Hi,
Instead of saying
x / 1024 / 1024 / 1024
you can say
x / POWER (2, 30)
or
x / POWER (1024, 3)
I define a substitution variable in my LOGIN.SQL file.
1024**3
2**30