Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine Datafile Bytes Used and Free 1

Status
Not open for further replies.

tekdudedude

Technical User
Sep 29, 2007
79
Hello,

For a given tablespace datafiles how can I determine each file's bytes used and bytes free?

I have been tinkering with dba_data_files and dba_tablespaces but I am confused as to which fields are doing what.

Thanks,

TD
 
Code:
select s.tablespace_name,  f.file_name, f.bytes as tot_size, s.free_space, 
f.bytes - s.free_space as used_space
from 
(select tablespace_name, file_id, sum(bytes) as free_space 
from sys.dba_free_space
group by tablespace_name, file_id) s,
sys.dba_data_files f
where s.file_id = f.file_id
and   s.tablespace_name = f.tablespace_name
 
Dagon,

Thanks for posting - that is perfect! :)

TD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top