Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL Help
Daniel Morgan wrote:
> Joe Philip wrote:
>
>
>>I want to find the free space and used space from a database. I wrote the >>following sql but does not work: >> >>select sum(a.bytes) free, sum(b.bytes) used >>from dba_free_space a, dba_segments b >>where a. tablespace_name=b.tablespace_name >>group by a.tablespace_name >>/ >> >>What am I doing wrong?
Daniel is quite correct. You may wish to try the following query:
/* If running this in a narrow (80 character) terminal emulator */
/* you may wish to cut the linesize down to match, in which case the
lines will wrap */
set pages 30
set linesize 200
clear columns
clear breaks
column tbsp format A25 heading 'Tablespace'
column filenam format A30 heading 'File'
column fsz format 99999.999 heading 'File Size MB'
column tott format 99999.999 heading 'Free MB'
column numm format 999999 heading 'No. of chunks'
column maxx format 99999.999 heading 'Max Chunk MB' column avgg format 99999.999 heading 'Avg Chunk MB' column minn format 99999.999 heading 'Min Chunk MB'break on tbsp skip1
max(fsp1.bytes)/(1024*1024) maxx, avg(fsp1.bytes)/(1024*1024) avgg, min(fsp1.bytes)/(1024*1024) minn
sys.dba_tablespaces ts1, sys.dba_data_files df1, sys.dba_free_space fsp1
The result will tell you not only how much space there is but also the number of chnuks it comes in etc..
You'll need to remove the formatting if using it in a tool other than SQL*Plus (e.g Toad). Run it as SYS or another account with relevant privileges.
John S. Findlay Received on Mon Aug 12 2002 - 12:20:56 CDT
![]() |
![]() |