DB CONTROL中表空間監控的SQL
SELECT /*+first_rows
*/
D.TABLESPACE_NAME,
NVL(A.BYTES / 1024 / 1024, 0) TOTAL_SIZE,
DECODE(D.CONTENTS,
'UNDO',
NVL(U.BYTES, 0) / 1024 / 1024,
NVL(A.BYTES - NVL(F.BYTES, 0), 0) / 1024 / 1024) USER_SIZE,
DECODE(D.CONTENTS,
'UNDO',
NVL(U.BYTES / A.BYTES * 100, 0),
NVL((A.BYTES - NVL(F.BYTES, 0)) / A.BYTES * 100, 0)) "USED%",
DECODE(D.CONTENTS,
'UNDO',
NVL(A.BYTES - NVL(U.BYTES, 0), 0) / 1024 / 1024,
NVL(F.BYTES, 0) / 1024 / 1024) FREE_SIZE,
D.STATUS,
A.COUNT,
D.CONTENTS,
D.EXTENT_MANAGEMENT,
D.SEGMENT_SPACE_MANAGEMENT
FROM SYS.DBA_TABLESPACES D,
(SELECT TABLESPACE_NAME, SUM(BYTES) BYTES, COUNT(FILE_ID) COUNT
FROM DBA_DATA_FILES
GROUP BY TABLESPACE_NAME) A,
(SELECT TABLESPACE_NAME, SUM(BYTES) BYTES
FROM DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) F,
(SELECT TABLESPACE_NAME, SUM(BYTES) BYTES
FROM (SELECT TABLESPACE_NAME, SUM(BYTES) BYTES, STATUS
FROM DBA_UNDO_EXTENTS
WHERE STATUS = 'ACTIVE'
GROUP BY TABLESPACE_NAME, STATUS
UNION ALL
SELECT TABLESPACE_NAME, SUM(BYTES) BYTES, STATUS
FROM DBA_UNDO_EXTENTS
WHERE STATUS = 'UNEXPIRED'
GROUP BY TABLESPACE_NAME, STATUS)
GROUP BY TABLESPACE_NAME) U
WHERE D.TABLESPACE_NAME = A.TABLESPACE_NAME(+)
AND D.TABLESPACE_NAME = F.TABLESPACE_NAME(+)
AND D.TABLESPACE_NAME = U.TABLESPACE_NAME(+)
AND NOT (D.EXTENT_MANAGEMENT = 'LOCAL' AND D.CONTENTS = 'TEMPORARY')
AND D.TABLESPACE_NAME LIKE '%%'
UNION ALL
SELECT D.TABLESPACE_NAME,
NVL(A.BYTES / 1024 / 1024, 0),
NVL(T.BYTES, 0) / 1024 / 1024,
NVL(T.BYTES / A.BYTES * 100, 0),
(NVL(A.BYTES, 0) / 1024 / 1024 - NVL(T.BYTES, 0) / 1024 / 1024),
D.STATUS,
A.COUNT,
D.CONTENTS,
D.EXTENT_MANAGEMENT,
D.SEGMENT_SPACE_MANAGEMENT
FROM SYS.DBA_TABLESPACES D,
(SELECT TABLESPACE_NAME, SUM(BYTES) BYTES, COUNT(FILE_ID) COUNT
FROM DBA_TEMP_FILES
GROUP BY TABLESPACE_NAME) A,
(SELECT SS.TABLESPACE_NAME,
SUM((SS.USED_BLOCKS * TS.BLOCKSIZE)) BYTES
FROM GV$SORT_SEGMENT SS, SYS.TS$ TS
WHERE SS.TABLESPACE_NAME = TS.NAME
GROUP BY SS.TABLESPACE_NAME) T
WHERE D.TABLESPACE_NAME = A.TABLESPACE_NAME(+)
AND D.TABLESPACE_NAME = T.TABLESPACE_NAME(+)
AND D.EXTENT_MANAGEMENT = 'LOCAL'
AND D.CONTENTS = 'TEMPORARY'
AND D.TABLESPACE_NAME LIKE '%%'
ORDER BY 1
注意UNDO,由於DBA_UNDO_EXTENTS底層x$的關係,在RAC的2個例項上查詢UNDO的利用率不一樣,例項1就看自己的undotbs1利用率,例項2看undotbs2的利用率。
D.TABLESPACE_NAME,
NVL(A.BYTES / 1024 / 1024, 0) TOTAL_SIZE,
DECODE(D.CONTENTS,
'UNDO',
NVL(U.BYTES, 0) / 1024 / 1024,
NVL(A.BYTES - NVL(F.BYTES, 0), 0) / 1024 / 1024) USER_SIZE,
DECODE(D.CONTENTS,
'UNDO',
NVL(U.BYTES / A.BYTES * 100, 0),
NVL((A.BYTES - NVL(F.BYTES, 0)) / A.BYTES * 100, 0)) "USED%",
DECODE(D.CONTENTS,
'UNDO',
NVL(A.BYTES - NVL(U.BYTES, 0), 0) / 1024 / 1024,
NVL(F.BYTES, 0) / 1024 / 1024) FREE_SIZE,
D.STATUS,
A.COUNT,
D.CONTENTS,
D.EXTENT_MANAGEMENT,
D.SEGMENT_SPACE_MANAGEMENT
FROM SYS.DBA_TABLESPACES D,
(SELECT TABLESPACE_NAME, SUM(BYTES) BYTES, COUNT(FILE_ID) COUNT
FROM DBA_DATA_FILES
GROUP BY TABLESPACE_NAME) A,
(SELECT TABLESPACE_NAME, SUM(BYTES) BYTES
FROM DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) F,
(SELECT TABLESPACE_NAME, SUM(BYTES) BYTES
FROM (SELECT TABLESPACE_NAME, SUM(BYTES) BYTES, STATUS
FROM DBA_UNDO_EXTENTS
WHERE STATUS = 'ACTIVE'
GROUP BY TABLESPACE_NAME, STATUS
UNION ALL
SELECT TABLESPACE_NAME, SUM(BYTES) BYTES, STATUS
FROM DBA_UNDO_EXTENTS
WHERE STATUS = 'UNEXPIRED'
GROUP BY TABLESPACE_NAME, STATUS)
GROUP BY TABLESPACE_NAME) U
WHERE D.TABLESPACE_NAME = A.TABLESPACE_NAME(+)
AND D.TABLESPACE_NAME = F.TABLESPACE_NAME(+)
AND D.TABLESPACE_NAME = U.TABLESPACE_NAME(+)
AND NOT (D.EXTENT_MANAGEMENT = 'LOCAL' AND D.CONTENTS = 'TEMPORARY')
AND D.TABLESPACE_NAME LIKE '%%'
UNION ALL
SELECT D.TABLESPACE_NAME,
NVL(A.BYTES / 1024 / 1024, 0),
NVL(T.BYTES, 0) / 1024 / 1024,
NVL(T.BYTES / A.BYTES * 100, 0),
(NVL(A.BYTES, 0) / 1024 / 1024 - NVL(T.BYTES, 0) / 1024 / 1024),
D.STATUS,
A.COUNT,
D.CONTENTS,
D.EXTENT_MANAGEMENT,
D.SEGMENT_SPACE_MANAGEMENT
FROM SYS.DBA_TABLESPACES D,
(SELECT TABLESPACE_NAME, SUM(BYTES) BYTES, COUNT(FILE_ID) COUNT
FROM DBA_TEMP_FILES
GROUP BY TABLESPACE_NAME) A,
(SELECT SS.TABLESPACE_NAME,
SUM((SS.USED_BLOCKS * TS.BLOCKSIZE)) BYTES
FROM GV$SORT_SEGMENT SS, SYS.TS$ TS
WHERE SS.TABLESPACE_NAME = TS.NAME
GROUP BY SS.TABLESPACE_NAME) T
WHERE D.TABLESPACE_NAME = A.TABLESPACE_NAME(+)
AND D.TABLESPACE_NAME = T.TABLESPACE_NAME(+)
AND D.EXTENT_MANAGEMENT = 'LOCAL'
AND D.CONTENTS = 'TEMPORARY'
AND D.TABLESPACE_NAME LIKE '%%'
ORDER BY 1
注意UNDO,由於DBA_UNDO_EXTENTS底層x$的關係,在RAC的2個例項上查詢UNDO的利用率不一樣,例項1就看自己的undotbs1利用率,例項2看undotbs2的利用率。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8242091/viewspace-673831/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle表空間增加監控Oracle
- 監控硬碟空間指令碼硬碟指令碼
- 解決imp匯入時,使用源DB中表空間名的問題
- AIX分頁(交換)空間的監控AI
- 監控oracle表空間指令碼Oracle指令碼
- 表空間監控(三)tablespace detailAI
- oracle空間使用監控指令碼Oracle指令碼
- linux 下監控磁碟空間Linux
- Oracle中表空間、表、索引的遷移Oracle索引
- 檢視ORACLE中表、表空間的大小Oracle
- 【SQL監控】SQL完全監控的指令碼SQL指令碼
- 表空間監控(二)datafile size detailAI
- 監控和管理Oracle UNDO表空間的使用Oracle
- 監控空間並自動刪除超出空間的最老的檔案
- JAMon監控SQL執行時間SQL
- DB2監控DB2
- Linux發郵件磁碟空間監控Linux
- oracle監控表空間,JOB,rman備份Oracle
- DB2 鎖的監控DB2
- Script:List SORT ACTIVITY監控臨時空間的使用
- 監控長時間執行的查詢(監控資料庫效能的SQL ) -- 轉資料庫SQL
- oracle 效能監控 <--轉至 陽光傾城 的空間Oracle
- SQL0286N.DB2表空間的pagesize問題SQLDB2
- 雲空間影片監控的可擴充套件性:適應不斷增長的監控需求套件
- 多臺ORACLE資料庫表空間監控方案Oracle資料庫
- [原創] 利用Oracle metric(threshold)監控表空間Oracle
- WINDOWS 環境下 監控ORACLE臨時表空間WindowsOracle
- sybase空間監控和死鎖檢測語句
- 利用Oracle threshold(度量閥值)監控表空間Oracle
- db2表空間DB2
- db2pd監控工具DB2
- db2 常見監控DB2
- 常用監控SQLSQL
- SQL Server自動化運維繫列:監控磁碟剩餘空間及SQL Server錯誤日誌SQLServer運維
- 監控寶SQL Server效能監控的功能和配置SQLServer
- 【DB寶41】監控利器PMM的使用--監控MySQL、PG、MongoDB、ProxySQL等MySqlMongoDB
- Sybase空間監控指令碼 btmbfe_sybase_space_use.sh指令碼
- 查詢資料庫系統中表空間的使用率資料庫