with table_spaces asthe result looks like this:
(select sum(bytes) / 1000000 mb_free, tablespace_name
from dba_free_space group by tablespace_name),
data_files as
(select f.tablespace_name
,bytes / 1000000 file_size_mb
,maxbytes / 1000000 file_size_max_mb
,autoextensible
,file_name
from dba_data_files f),
schemas as
(select distinct owner, tablespace_name from dba_segments)
select s.owner
,t.tablespace_name
,round((t.file_size_mb-d.mb_free),2) file_size_mb
,round(((t.file_size_mb-d.mb_free) / t.file_size_mb) * 100,2) percent_content_vs_filesize
,round(t.file_size_mb,2) file_size_mb
,round((t.file_size_mb / t.file_size_max_mb) * 100,2) perc_content_vs_filesize_max
,round(t.file_size_max_mb,2) file_size_max_mb
,autoextensible
,t.file_name
from data_files t
join table_spaces d on d.tablespace_name = t.tablespace_name
left join schemas s on s.tablespace_name = d.tablespace_name
order by s.owner, t.tablespace_name
If you are only interested in the tablespace-datafile relation you can use this query:
with daten asThis is the result:
(select sum(bytes) / 1000000 mb_free, tablespace_name
from dba_free_space group by tablespace_name),
data_files as
(select f.tablespace_name
,bytes / 1000000 file_size_mb
,maxbytes / 1000000 file_size_max_mb
,autoextensible
from dba_data_files f)
select t.tablespace_name
,round((t.file_size_mb-d.mb_free),2) file_size_mb
,round(((t.file_size_mb-d.mb_free) / t.file_size_mb) * 100,2) percent_content_vs_filesize
,round(t.file_size_mb,2) file_size_mb
,round((t.file_size_mb / t.file_size_max_mb) * 100,2) perc_content_vs_filesize_max
,round(t.file_size_max_mb,2) file_size_max_mb
,autoextensible
from data_files t
join daten d on d.tablespace_name = t.tablespace_name
order by t.tablespace_name
The queries can help to identfiy how much space is left in a tablespace or datafile. Or you can identify how big the datafiles can be in maximum. And of course you can identfiy the default datafiles which are created by apex when you don't use any external script. In normal case these datafiles are named like: APEX_XXXXXXXXXX.