ORACLE表空间使用情况及状态SQL

select
    tablespace_name,
    max,
    alloc,
    used,
    round(100 * used / alloc, 2) pct_used_alloc,
    round(100 * used / max, 2) pct_used_max,
    status,
    logging,
    force_logging,
    extent_management,
    allocation_type
from
    (
    select
        t.status status,
        t.logging logging,
        t.force_logging force_logging,
        t.extent_management extent_management,
        t.allocation_type allocation_type,
        a.tablespace_name tablespace_name,
        round(a.bytes_alloc , 2) alloc,
        round((a.bytes_alloc - nvl(b.bytes_free, 0)) , 2) used,
        round(a.maxbytes , 2) max
    from
        dba_tablespaces t,
        (
        select
            f.tablespace_name,
            sum(f.bytes) bytes_alloc,
            sum(decode(f.autoextensible, 'YES', f.maxbytes, 'NO', f.bytes)) maxbytes
        from
            dba_data_files f
        group by
            tablespace_name) a,
        (
        select
            f.tablespace_name,
            sum(f.bytes) bytes_free
        from
            dba_free_space f
        group by
            tablespace_name) b
    where
        a.tablespace_name = b.tablespace_name(+)
        and a.tablespace_name = t.tablespace_name
union all
    select
        t.status status,
        t.logging logging,
        t.force_logging force_logging,
        t.extent_management extent_management,
        t.allocation_type allocation_type,
        h.tablespace_name tablespace_name,
        round(sum(nvl(f.bytes, 0)) , 2) alloc,
        round(sum(nvl(p.bytes_used, 0)) , 2) used,
        round(sum(decode(f.autoextensible, 'YES', f.maxbytes, 'NO', f.bytes)) , 2) max
    from
        dba_tablespaces t,
        v$temp_space_header h,
        v$temp_extent_pool p,
        dba_temp_files f
    where
        p.file_id(+) = h.file_id
        and p.tablespace_name(+) = h.tablespace_name
        and f.file_id = h.file_id
        and f.tablespace_name = h.tablespace_name
        and t.tablespace_name = h.tablespace_name
    group by
        h.tablespace_name,
        t.status,
        t.logging,
        t.force_logging,
        t.extent_management,
        t.allocation_type )
order by
    4

 

TABLESPACE_NAMEMAXALLOCUSEDPCT_USED_ALLOCPCT_USED_MAXSTATUSLOGGINGFORCE_LOGGINGEXTENT_MANAGEMENTALLOCATION_TYPE
TEMP34,359,721,9841,342,177,2801,048,5760.080ONLINENOLOGGINGNOLOCALUNIFORM
USERS34,359,721,9845,242,8801,376,25626.250ONLINELOGGINGNOLOCALSYSTEM
TESTTBS68,719,443,968209,715,2002,097,15210ONLINELOGGINGNOLOCALSYSTEM
UNDOTBS134,359,721,98494,371,84021,626,88022.920.06ONLINELOGGINGNOLOCALSYSTEM
SYSAUX34,359,721,984587,202,560553,451,52094.251.61ONLINELOGGINGNOLOCALSYSTEM
SYSTEM34,359,721,984786,432,000779,747,32899.152.27ONLINELOGGINGNOLOCALSYSTEM
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值