如何编写Oracle查询表空间的每日增长量和历史情况统计的脚本
发表于:2024-10-23 作者:千家信息网编辑
千家信息网最后更新 2024年10月23日,如何编写Oracle查询表空间的每日增长量和历史情况统计的脚本,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。今天主要总结
千家信息网最后更新 2024年10月23日如何编写Oracle查询表空间的每日增长量和历史情况统计的脚本
如何编写Oracle查询表空间的每日增长量和历史情况统计的脚本,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
今天主要总结一下Oracle表空间每日增长和历史情况统计的一些脚本,仅供参考。
11g统计表空间的每日增长量
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统计表空间的每日增长量
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 数据库,数据库对象历史增长情况
最近七天数据库的增长情况,这个只是一个估算值。
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
查看数据库历史增长情况
此处是通过计算数据库所有表空间的历史增长情况来计算数据库历史情况。
不含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
列出相关段对象在 快照时间内的使用空间的历史变化信息
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;
看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注行业资讯频道,感谢您对的支持。
增长
历史
情况
空间
数据
数据库
统计
增长量
脚本
对象
统计表
帮助
查询表
查询
清楚
仅供参考
信息
内容
只是
对此
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
话唠软件开发
关系数据库中的关系必须满足
困境儿童数据库怎么建立
本地登录服务器
中兴南京无线大数据软件开发五部
小程序更换服务器收费
驾驶员网络安全培训
分频器设计软件开发
冒险岛2多线服务器
诺基亚套件无法连接服务器
服务器怎么测显卡是否正常
本地域名服务器和权威域名服务器
信息技术八年级上网络安全
网络安全大会上的讲话
青岛帕丁顿网络技术有限公司
国际间网络安全
科学文摘数据库
以色列网络安全突破性技术
山西运营软件开发介绍
逐鹿三国手游数据库
专科网络安全好就业吗
雅好网络技术
哪个数据库可以查找外文文献
nyit的网络安全专业排名
方舟进去别人服务器怎么开代码
visio服务器图标
信息技术八年级上网络安全
网络安全调研报告总结
服务器更改管理员名臣
中学生网络安全资料内容