【APM】Oracle表空间详细信息查询语句

【APM】Oracle表空间详细信息查询语句

对于 12C 及以上版本:
SELECT t.tablespace_name,t.contents,t.status,NVL(df.allocated_bytes,0) allocatedbytes, NVL(df.allocated_bytes,0)-(NVL(f.free_blocks*t.block_size,0)+NVL(df.max_free_bytes,0)+(NVL(unused_free_blocks,0)*t.block_size)) usedBytes,(NVL(f.free_blocks*t.block_size,0)+NVL(df.max_free_bytes,0)+(NVL(unused_free_blocks,0)*t.block_size)) freeBytes, NVL(df.allocated_blocks,0) allocatedBlocks,(NVL(f.free_blocks,0)+NVL(unused_free_blocks,0))+(NVL(df.max_free_bytes,0)/t.block_size)  freeBlocks FROM sys.dba_tablespaces t, (select name as tablespace_name,sum(ff.free_blocks) free_blocks from (SELECT t.name, sum(fs.blocks) free_blocks FROM sys.DBA_LMT_FREE_SPACE fs join V$TABLESPACE t on fs.tablespace_id=t.ts# and con_id in (select con_id from V$MYSTAT) GROUP BY t.name union SELECT t.name, sum(fs.blocks) free_blocks FROM sys.DBA_DMT_FREE_SPACE fs join V$TABLESPACE t on fs.tablespace_id=t.ts# and con_id in (select con_id from V$MYSTAT) GROUP BY t.name) ff group by name) f , (select dff.tablespace_name,sum(dff.allocated_bytes) allocated_bytes,sum(dff.max_free_bytes) max_free_bytes, sum(dff.allocated_blocks) allocated_blocks from (select dfs.tablespace_name,dfs.autoextensible, sum(decode(sign(dfs.maxbytes-dfs.bytes),1,dfs.maxbytes,dfs.bytes)) allocated_bytes, sum(decode(sign(dfs.maxbytes-dfs.bytes),1,abs(dfs.maxbytes-dfs.bytes),0)) max_free_bytes, sum(decode(sign(dfs.maxblocks-dfs.blocks),1,dfs.maxblocks,dfs.blocks)) allocated_blocks from dba_data_files dfs group by dfs.tablespace_name,dfs.autoextensible)dff group by dff.tablespace_name)df, (select ts_name,sum(space) unused_free_blocks from dba_recyclebin group by ts_name)rc WHERE t.tablespace_name = f.tablespace_name(+) and t.tablespace_name = df.tablespace_name(+) and t.tablespace_name = rc.ts_name(+) order by tablespace_name

    • Related Articles

    • 【APM】Oracle Alert Log 查询语句

      对于 Oracle 12C 以下版本获取Oracle Alert Log的查询语句是: SELECT decode(MESSAGE_LEVEL,1,'CRITICAL',2,'SEVERE',8,'IMPORTANT',16,'NORMAL',MESSAGE_LEVEL) as MESSAGE_LEVEL,RECORD_ID,ORIGINATING_TIMESTAMP,HOST_ADDRESS,MESSAGE_TEXT FROM v$appman_alertlog_ext WHERE TRIM ...
    • 【APM】Oracle ‘OracleInvaildObjects’查询组查询语句

      如出现: 1.由于此查询组导致套接字读取超时OracleInvaildObjects 2.由于此查询组导致查询组超时OracleInvaildObjects 首先编辑监视器,设置套接字超时时间和查询组超时时间为 300s。 如已设置为 300s,可通过在 Oracle DB 上执行下列查询,看执行时间: SELECT OWNER, OBJECT_NAME, STATUS as OBJECT_STATUS FROM DBA_OBJECTS WHERE STATUS='INVALID' and ...
    • 【APM】Oracle ‘INSTANCESTATUS’查询组查询语句

      如出现: 1.由于此查询组导致套接字读取超时INSTANCESTATUS 2.由于此查询组导致查询组超时INSTANCESTATUS 首先编辑监视器,设置套接字超时时间和查询组超时时间为 300s。 如已设置为 300s,可通过在 Oracle DB 上执行下列查询,看执行时间: SELECT COUNT(0) avg_users_cursor FROM v$session WHERE (username IS NOT NULL) AND (TYPE!='BACKGROUND') AND ...
    • 【APM】Oracle ‘RollBack’查询组查询语句

      如出现: 1.由于此查询组导致套接字读取超时RollBack 2.由于此查询组导致查询组超时RollBack 首先编辑监视器,设置套接字超时时间和查询组超时时间为 300s。 如已设置为 300s,可通过在 Oracle DB 上执行下列查询,看执行时间: SELECT (r.segment_name || '_' || r.tablespace_name) as SegmentId, r.initial_extent, r.next_extent, r.min_extents, ...
    • 【APM】Oracle ‘OracleDiskGroupgs’查询组查询语句

      如出现: 1.由于此查询组导致套接字读取超时OracleDiskGroupgs 2.由于此查询组导致查询组超时OracleDiskGroupgs 首先编辑监视器,设置套接字超时时间和查询组超时时间为 300s。 如已设置为 300s,可通过在 Oracle DB 上执行下列查询,看执行时间: select GROUP_NUMBER,NAME,STATE,TYPE,TOTAL_MB,FREE_MB from V$ASM_DISKGROUP 如执行时间没有过久,并且上述超时时间已设置为 300s ...