久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

如何編寫Oracle查詢表空間的每日增長量和歷史情況統(tǒng)計的腳本

128次閱讀
沒有評論

共計 4573 個字符,預(yù)計需要花費 12 分鐘才能閱讀完成。

如何編寫 Oracle 查詢表空間的每日增長量和歷史情況統(tǒng)計的腳本,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面丸趣 TV 小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。

今天主要總結(jié)一下 Oracle 表空間每日增長和歷史情況統(tǒng)計的一些腳本,僅供參考。

11g 統(tǒng)計表空間的每日增長量

SELECT a.snap_id, c.tablespace_name ts_name, to_char(to_date(a.rtime,  mm/dd/yyyy hh34:mi:ss),  yyyy-mm-dd hh34:mi ) rtime, round(a.tablespace_size * c.block_size / 1024 / 1024, 2) ts_size_mb, round(a.tablespace_usedsize * c.block_size / 1024 / 1024, 2) ts_used_mb, round((a.tablespace_size - a.tablespace_usedsize) * c.block_size / 1024 / 1024, 2) ts_free_mb, round(a.tablespace_usedsize / a.tablespace_size * 100, 2) pct_used FROM dba_hist_tbspc_space_usage a, (SELECT tablespace_id, substr(rtime, 1, 10) rtime, max(snap_id) snap_id FROM dba_hist_tbspc_space_usage nb group by tablespace_id, substr(rtime, 1, 10)) b, dba_tablespaces c, v$tablespace d where a.snap_id = b.snap_id and a.tablespace_id = b.tablespace_id and a.tablespace_id = d.TS# and d.NAME = c.tablespace_name and to_date(a.rtime,  mm/dd/yyyy hh34:mi:ss)  = sysdate - 30 order by a.tablespace_id, to_date(a.rtime,  mm/dd/yyyy hh34:mi:ss) desc;

12c 統(tǒng)計表空間的每日增長量

SELECT a.snap_id, a.con_id, e.name pdbname, c.tablespace_name ts_name, to_char(to_date(a.rtime,  mm/dd/yyyy hh34:mi:ss),  yyyy-mm-dd hh34:mi ) rtime, round(a.tablespace_size * c.block_size / 1024 / 1024, 2) ts_size_mb, round(a.tablespace_usedsize * c.block_size / 1024 / 1024, 2) ts_used_mb, round((a.tablespace_size - a.tablespace_usedsize) * c.block_size / 1024 / 1024, 2) ts_free_mb, round(a.tablespace_usedsize / a.tablespace_size * 100, 2) pct_used FROM cdb_hist_tbspc_space_usage a, (SELECT tablespace_id, nb.con_id, substr(rtime, 1, 10) rtime, max(snap_id) snap_id FROM dba_hist_tbspc_space_usage nb group by tablespace_id, nb.con_id,substr(rtime, 1, 10)) b, cdb_tablespaces c, v$tablespace d, V$CONTAINERS e where a.snap_id = b.snap_id and a.tablespace_id = b.tablespace_id and a.con_id=b.con_id and a.con_id=c.con_id and a.con_id=d.con_id and a.con_id=e.con_id and a.tablespace_id=d.TS# and d.NAME=c.tablespace_name and to_date(a.rtime,  mm/dd/yyyy hh34:mi:ss)  =sysdate-30 order by a.CON_ID,a.tablespace_id,to_date(a.rtime,  mm/dd/yyyy hh34:mi:ss) desc;

估算 oracle 數(shù)據(jù)庫,數(shù)據(jù)庫對象歷史增長情況

最近七天數(shù)據(jù)庫的增長情況,這個只是一個估算值。

select sum(space_used_total) / 1024 / 1024 / 1024  last 7 days db increase - G  from dba_hist_seg_stat s, dba_hist_seg_stat_obj o, dba_hist_snapshot sn where s.obj# = o.obj# and ssn.snap_id = s.snap_id and begin_interval_time   sysdate - 8 order by begin_interval_time

查看數(shù)據(jù)庫歷史增長情況

此處是通過計算數(shù)據(jù)庫所有表空間的歷史增長情況來計算數(shù)據(jù)庫歷史情況。

不含 undo 和 temp:

with tmp as ( select rtime,sum(tablespace_usedsize_kb) tablespace_usedsize_kb, sum(tablespace_size_kb) tablespace_size_kb from (select rtime, e.tablespace_id, (e.tablespace_usedsize)*(f.block_size)/1024 tablespace_usedsize_kb, (e.tablespace_size)*(f.block_size)/1024 tablespace_size_kb from dba_hist_tbspc_space_usage e, dba_tablespaces f, v$tablespace g where e.tablespace_id = g.TS# and f.tablespace_name = g.NAME and f.contents not in (TEMPORARY , UNDO)) group by rtime) select tmp.rtime, tablespace_usedsize_kb, tablespace_size_kb,(tablespace_usedsize_kb - LAG(tablespace_usedsize_kb, 1, NULL) OVER(ORDER BY tmp.rtime)) AS DIFF_KB from tmp, (select max(rtime) rtime from tmp group by substr(rtime, 1, 10)) t2 where t2.rtime = tmp.rtime;

含 undo 和 temp:

with tmp as ( select min(rtime) rtime, sum(tablespace_usedsize_kb) tablespace_usedsize_kb, sum(tablespace_size_kb) tablespace_size_kb from (select rtime, e.tablespace_id, (e.tablespace_usedsize) * (f.block_size) / 1024 tablespace_usedsize_kb, (e.tablespace_size) * (f.block_size) / 1024 tablespace_size_kb from dba_hist_tbspc_space_usage e, dba_tablespaces f, v$tablespace g where e.tablespace_id = g.TS# and f.tablespace_name = g.NAME) group by rtime) select tmp.rtime, tablespace_usedsize_kb, tablespace_size_kb, (tablespace_usedsize_kb-LAG(tablespace_usedsize_kb, 1, NULL) OVER(ORDER BY tmp.rtime)) AS DIFF_KB from tmp, (select min(rtime) rtime from tmp group by substr(rtime, 1, 10)) t2 where t2.rtime = tmp.rtime

列出相關(guān)段對象在 快照時間內(nèi)的使用空間的歷史變化信息

select obj.owner, obj.object_name, to_char(sn.BEGIN_INTERVAL_TIME,  RRRR-MON-DD) start_day, sum(a.db_block_changes_delta) block_increase from dba_hist_seg_stat a, dba_hist_snapshot sn, dba_objects obj where sn.snap_id = a.snap_id and obj.object_id = a.obj# and obj.owner not in (SYS ,  SYSTEM) and end_interval_time between to_timestamp(01-OCT-2019 ,  DD-MON-RRRR) and to_timestamp(09-OCT-2019 ,  DD-MON-RRRR) group by obj.owner, obj.object_name, to_char(sn.BEGIN_INTERVAL_TIME,  RRRR-MON-DD) order by obj.owner, obj.object_name;

看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進一步的了解或閱讀更多相關(guān)文章,請關(guān)注丸趣 TV 行業(yè)資訊頻道,感謝您對丸趣 TV 的支持。

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-07-17發(fā)表,共計4573字。
轉(zhuǎn)載說明:除特殊說明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 朝阳县| 彩票| 常熟市| 大新县| 筠连县| 新闻| 平阳县| 晋州市| 隆回县| 鄂伦春自治旗| 根河市| 蒙阴县| 浮山县| 三门峡市| 绥棱县| 武平县| 紫阳县| 扬州市| 上栗县| 焉耆| 布拖县| 右玉县| 兴业县| 内丘县| 汉沽区| 奉化市| 波密县| 杭锦旗| 积石山| 楚雄市| 汪清县| 甘洛县| 杭锦后旗| 临洮县| 吉林省| 津南区| 临夏县| 雷州市| 运城市| 景宁| 三亚市|