不含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;

【编辑推荐】 - 10月数据库排行:Microsoft SQL Server 分数增加最多
- 分享一份大佬的MySQL数据库设计规范,值得收藏
- 传统数据库不适合现代企业架构了?
- MySQL数据库基础篇之入门基础命令
- MySQL数据库入门多实例配置
【责任编辑:赵宁宁 TEL:(010)68476606】
点赞 0 (编辑:晋中站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|