Я считаю, что вам нужны данные в DBA_SEGMENTS. Например, вы могли бы перечислить все схемы с объектами в табличном пространстве «USERS» следующим образом:
select tablespace_name, owner
, round(sum(bytes) / (1024*1024) , 1) mb_used_in_ts
from dba_segments
where 1=1
and tablespace_name = 'USERS'
group by tablespace_name, owner
;
Следующий запрос делает немного больше, чем вы просили, но вы должны найти его полезным:
with ts_name as
(
select 'DEFAULT' tablespace_type
, DEFAULT_TABLESPACE tablespace_name
from dba_users where username = upper(:username)
union
select 'INDEX' tablespace_type
, substr(default_tablespace, 1, instr(default_tablespace, '_DATA'))||'INDEX' tablespace_name
from dba_users where username = upper(:username)
union
select 'Data?' tablespace_type
, upper(:username) || '_DATA' tablespace_name
from dual
union
select 'Index?' tablespace_type
, upper(:username) || '_INDEX' tablespace_name
from dual
union
select ':tablespace input' tablespace_type
, upper(:tablespace) tablespace_name
from dual
union
select ':tablespace2 input' tablespace_type
, upper(:tablespace2) tablespace_name
from dual
)
SELECT to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS') date_checked
, df.tablespace_name "Tablespace"
, nvl(totalusedspace, 0) "Used MB"
, nvl((df.totalspace - tu.totalusedspace), df.totalspace) "Free MB"
, df.totalspace "Total MB"
, nvl(ROUND (100 * ((df.totalspace - tu.totalusedspace) / df.totalspace)), 100) "Pct. Free"
, (select SEGMENT_SPACE_MANAGEMENT
from dba_tablespaces a
where a.tablespace_name = df.tablespace_name) SEGMENT_SPACE_MANAGEMENT
FROM (SELECT tablespace_name, ROUND (SUM (BYTES) / (1024*1024)) totalspace
FROM dba_data_files
GROUP BY tablespace_name) df,
(SELECT ROUND (SUM (BYTES) / (1024 * 1024)) totalusedspace,
tablespace_name
FROM dba_segments
GROUP BY tablespace_name) tu
WHERE df.tablespace_name = tu.tablespace_name (+)
AND df.tablespace_name in (select tablespace_name from ts_name)
order by 6
;