--查詢前一週表空間增加狀況
SELECT C.TABLESPACE_NAME,
D."Total(MB)",
D."Used(MB)" - C."Used(MB)" AS "Increment(MB)",
TO_CHAR(NEXT_DAY(TRUNC(SYSDATE), 2) - 7, 'yyyy/mm/dd') || '--' ||
TO_CHAR(NEXT_DAY(TRUNC(SYSDATE), 2) - 7, 'yyyy/mm/dd') "TIME"
FROM (SELECT B.NAME TABLESPACE_NAME,
CASE
WHEN B.NAME NOT LIKE 'UNDO%' THEN
ROUND(A.TABLESPACE_SIZE * 8 / 1024)
WHEN B.NAME LIKE 'UNDO%' THEN
ROUND(A.TABLESPACE_SIZE * 8 / 1024 / 2)
END AS "Total(MB)",
ROUND(A.TABLESPACE_USEDSIZE * 8 / 1024) "Used(MB)",
A.RTIME
FROM DBA_HIST_TBSPC_SPACE_USAGE A, V$TABLESPACE B
WHERE A.TABLESPACE_ID = B.TS#
AND TO_CHAR(TO_DATE(REPLACE(RTIME, '/', NULL),
'mmddyyyy hh24:mi:ss'),
'yyyymmdd hh24:mi') =
TO_CHAR(NEXT_DAY(TRUNC(SYSDATE), 2) - 14, 'yyyymmdd hh24:mi')) C,
(SELECT B.NAME TABLESPACE_NAME,
CASE
WHEN B.NAME NOT LIKE 'UNDO%' THEN
ROUND(A.TABLESPACE_SIZE * 8 / 1024)
WHEN B.NAME LIKE 'UNDO%' THEN
ROUND(A.TABLESPACE_SIZE * 8 / 1024 / 2)
END AS "Total(MB)",
ROUND(A.TABLESPACE_USEDSIZE * 8 / 1024) "Used(MB)",
A.RTIME
FROM DBA_HIST_TBSPC_SPACE_USAGE A, V$TABLESPACE B
WHERE A.TABLESPACE_ID = B.TS#
AND TO_CHAR(TO_DATE(REPLACE(RTIME, '/', NULL),
'mmddyyyy hh24:mi:ss'),
'yyyymmdd hh24:mi') =
TO_CHAR(NEXT_DAY(TRUNC(SYSDATE), 2) - 7, 'yyyymmdd hh24:mi')) D
WHERE C.TABLESPACE_NAME = D.TABLESPACE_NAME;對象
--查詢前一天表空間增加狀況rem
SELECT C.TABLESPACE_NAME,
D."Total(MB)",
D."Used(MB)" - C."Used(MB)" AS "Increment(MB)",
TO_CHAR(TRUNC(SYSDATE - 1), 'yyyy/mm/dd') "TIME"
FROM (SELECT B.NAME TABLESPACE_NAME,
CASE
WHEN B.NAME NOT LIKE 'UNDO%' THEN
ROUND(A.TABLESPACE_SIZE * 8 / 1024)
WHEN B.NAME LIKE 'UNDO%' THEN
ROUND(A.TABLESPACE_SIZE * 8 / 1024 / 2)
END AS "Total(MB)",
ROUND(A.TABLESPACE_USEDSIZE * 8 / 1024) "Used(MB)",
A.RTIME
FROM DBA_HIST_TBSPC_SPACE_USAGE A, V$TABLESPACE B
WHERE A.TABLESPACE_ID = B.TS#
AND TO_CHAR(TO_DATE(REPLACE(RTIME, '/', NULL),
'mmddyyyy hh24:mi:ss'),
'yyyymmdd hh24:mi') =
TO_CHAR(TRUNC(SYSDATE - 1), 'yyyymmdd hh24:mi')) C,
(SELECT B.NAME TABLESPACE_NAME,
CASE
WHEN B.NAME NOT LIKE 'UNDO%' THEN
ROUND(A.TABLESPACE_SIZE * 8 / 1024)
WHEN B.NAME LIKE 'UNDO%' THEN
ROUND(A.TABLESPACE_SIZE * 8 / 1024 / 2)
END AS "Total(MB)",
ROUND(A.TABLESPACE_USEDSIZE * 8 / 1024) "Used(MB)",
A.RTIME
FROM DBA_HIST_TBSPC_SPACE_USAGE A, V$TABLESPACE B
WHERE A.TABLESPACE_ID = B.TS#
AND TO_CHAR(TO_DATE(REPLACE(RTIME, '/', NULL),
'mmddyyyy hh24:mi:ss'),
'yyyymmdd hh24:mi') =
TO_CHAR(TRUNC(SYSDATE), 'yyyymmdd hh24:mi')) D
WHERE C.TABLESPACE_NAME = D.TABLESPACE_NAME;
--在得知哪一個表空間增加明顯的狀況下,再去查詢該表空間的對象大小狀況,TABLESPACE_NAME爲某表空間名稱
SELECT OWNER, SEGMENT_NAME, SEGMENT_TYPE, BYTES / 1024 / 1024 / 1024 GB
FROM DBA_SEGMENTS
WHERE TABLESPACE_NAME ='&TABLESPACE_NAME'
ORDER BY BYTES DESC;sed
SELECT *
FROM (SELECT OWNER,
SEGMENT_NAME,
SEGMENT_TYPE,
BYTES / 1024 / 1024 / 1024 GB
FROM DBA_SEGMENTS
WHERE TABLESPACE_NAME ='&TABLESPACE_NAME'
ORDER BY BYTES DESC)
WHERE ROWNUM < 30;
--如何肯定某些對象容量增漲快,須要必定時間的跟蹤,週期性查詢該對象的容量。而後根據對象作相應後續處理。查詢