—查看表空间
    SELECT a.tablespace_name “表空间名”,
    total “表空间大小”,
    free “表空间剩余大小”,
    (total - free) “表空间使用大小”,
    total / (1024 1024 1024) “表空间大小(G)”,
    free / (1024 1024 1024) “表空间剩余大小(G)”,
    (total - free) / (1024 1024 1024) “表空间使用大小(G)”,
    round((total - free) / total, 4) * 100 “使用率 %”
    FROM (SELECT tablespace_name, SUM(bytes) free
    FROM dba_free_space
    GROUP BY tablespace_name) a,
    (SELECT tablespace_name, SUM(bytes) total
    FROM dba_data_files
    GROUP BY tablespace_name) b
    WHERE a.tablespace_name = b.tablespace_name;

    —考虑可自动扩展的空间
    col tablespace_name format a16
    col EXTENT_MANAGEMENT format a17
    col SUM_MB format 9999999999
    set linesize 1000
    col FREE_MB format 9999999
    select c.tablespace_name, d.status, d.contents, d.EXTENT_MANAGEMENT, c.sum_MB, c.free_MB, c.use_precent
    from
    (select b.tablespace_name,round(sum(decode(b.AUTOEXTENSIBLE,’YES’,b.MAXBYTES,b.bytes))/1024/1024,0) sum_MB,
    round(sum(nvl(a.bytes,0)+decode(b.AUTOEXTENSIBLE,’YES’,b.MAXBYTES-b.USER_BYTES,0))/1024/1024,0) free_MB,
    round((sum(decode(b.AUTOEXTENSIBLE,’YES’,b.MAXBYTES,b.bytes))-sum(nvl(a.bytes,0)+decode(b.AUTOEXTENSIBLE,’YES’,b.MAXBYTES-b.USER_BYTES,0)))/sum(decode(b.AUTOEXTENSIBLE,’YES’,b.MAXBYTES,b.bytes)),4)*100 use_precent
    from (select tablespace_name,file_id,sum(bytes) bytes from dba_free_space group by tablespace_name,file_id ) a,
    dba_data_files b
    where a.file_id(+)=b.file_id and a.tablespace_name(+)=b.tablespace_name
    group by b.tablespace_name
    ) c, dba_tablespaces d
    where c.tablespace_name = d.tablespace_name
    order by c.use_precent desc;