oracle table ,database growth report script「建议收藏」

oracle table ,database growth report script「建议收藏」@seg_top_logreads_10g.sql select object_name “Object Name” , tablespace_name “Tablespace Name” , ob…

oracle table ,database growth report script


@seg_top_logreads_10g.sql
select
    object_name "Object Name"
  , tablespace_name "Tablespace Name"
  , object_type "Object Type"
  , logical_reads_total "Logical Reads"
  , ratio "%Total"
from(
select n.owner||"."||n.object_name||decode(n.subobject_name,null,null,"."||n.subobject_name) object_name
     , n.tablespace_name
     , case when length(n.subobject_name) < 11 then
              n.subobject_name
            else
              substr(n.subobject_name,length(n.subobject_name)-9)
       end subobject_name
     , n.object_type
     , r.logical_reads_total
     , round(r.ratio * 100, 2) ratio
  from dba_hist_seg_stat_obj  n
     , (select *
          from (select e.dataobj#
                     , e.obj#
                     , e.dbid
                     , e.logical_reads_total - nvl(b.logical_reads_total, 0) logical_reads_total
                     , ratio_to_report(e.logical_reads_total - nvl(b.logical_reads_total, 0)) over () ratio
                 from dba_hist_seg_stat  e
                     , dba_hist_seg_stat  b
                 where b.snap_id  = 2694
                   and e.snap_id  = 2707
                   and b.dbid     = 37933856   
                   and e.dbid     = 37933856
                   and b.instance_number  = 1
                   and e.instance_number  = 1
                   and e.obj#             = b.obj#
                   and e.dataobj#         = b.dataobj#
               and e.logical_reads_total - nvl(b.logical_reads_total, 0)  > 0
                 order by logical_reads_total desc) d
          where rownum <= 100) r
 where n.dataobj# = r.dataobj#
SEE CODE DEPOT FOR FULL SCRIPTS

)

order by logical_reads_total desc;

代码100分

代码100分
@table_growth_status 
set serveroutput on     
    execute dbms_output.enable(buffer_size => NULL);**


    Declare
          v_BaselineSize  number(20);
          v_CurrentSize   number(20);
          v_TotalGrowth   number(20);
          v_Space     number(20);
          cursor usageHist is
                  select a.snap_id,
                  SNAP_TIME,
                  sum(TOTAL_SPACE_ALLOCATED_DELTA) over ( order by a.SNAP_ID) ProgSum
              from
 (select SNAP_ID,
                      sum(SPACE_ALLOCATED_DELTA) TOTAL_SPACE_ALLOCATED_DELTA
                  from DBA_HIST_SEG_STAT
                  group by SNAP_ID
                  having sum(SPACE_ALLOCATED_TOTAL) <> 0
                  order by 1 ) a,
                  (select distinct SNAP_ID,
                      to_char(END_INTERVAL_TIME,"DD-Mon-YYYY HH24:Mi") SNAP_TIME
                  from DBA_HIST_SNAPSHOT) b
              where a.snap_id=b.snap_id;
      Begin
          select sum(SPACE_ALLOCATED_DELTA) into v_TotalGrowth from DBA_HIST_SEG_STAT;
          select sum(bytes) into v_CurrentSize from dba_segments;
          v_BaselineSize := v_CurrentSize - v_TotalGrowth ;

          dbms_output.put_line("SNAP_TIME           Database Size(MB)");

          for row in usageHist loop
                  v_Space := (v_BaselineSize + row.ProgSum)/(1024*1024);
              dbms_output.put_line(row.SNAP_TIME || "           " || to_char(v_Space) );
          end loop;
      end;

@Oracle growth report at the table level
set feedback off
set pages 80
set linesize 150
spool /tmp/weekly_growth.txt
 
ttitle "Total Disk Used"
 
select sum(space_used_delta) / 1024 / 1024 "Space used (M)", sum(c.bytes) / 1024 / 1024 "Total Schema Size (M)",
round(sum(space_used_delta) / sum(c.bytes) * 100, 2) || "%" "Percent of Total Disk Usage"
from 
   dba_hist_snapshot sn, 
   dba_hist_seg_stat a, 
   dba_objects b, 
   dba_segments c
where end_interval_time > trunc(sysdate) - &days_back
and sn.snap_id = a.snap_id
and b.object_id = a.obj#
and b.owner = c.owner
and b.object_name = c.segment_name
and c.owner = "&schema_name"
and space_used_delta > 0;
 
ttitle "Total Disk Used by Object Type"
 
select c.segment_type, sum(space_used_delta) / 1024 / 1024 "Space used (M)", sum(c.bytes) / 1024 / 1024 "Total Space (M)",
round(sum(space_used_delta) / sum(c.bytes) * 100, 2) || "%" "Percent of Total Disk Usage"
from 
   dba_hist_snapshot sn, 
   dba_hist_seg_stat a, 
   dba_objects b, 
   dba_segments c
where end_interval_time > trunc(sysdate) - &days_back
and sn.snap_id = a.snap_id
and b.object_id = a.obj#
and b.owner = c.owner
and b.object_name = c.segment_name
and space_used_delta > 0
and c.owner = "&schema_name"
group by rollup(segment_type);
spool off
代码100分@top_grow_seg
select
so.owner,
so.object_name,
--so.subobject_name,
so.object_type,
so.tablespace_name,
round(sum(ss.space_used_delta)/1024/1024) growth_mb
from
dba_hist_seg_stat ss,
dba_hist_seg_stat_obj so
where
ss.obj# = so.obj#
and ss.dataobj# = so.dataobj#
and so.owner != "** MISSING **" -- segments already gone
and so.object_name not like "BIN$%" -- recycle-bin
and so.object_type not like "LOB%"
and ss.snap_id > (
select min(sn.snap_id)
from dba_hist_snapshot sn
where
sn.dbid = (select dbid from v$database)
and sn.end_interval_time > trunc(sysdate) - &DAYS_BACK
)
group by
so.owner,
so.object_name,
--so.subobject_name,
so.object_type,
so.tablespace_name
order by 5 desc
fetch first &TOP rows only;

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/10035.html

(0)
上一篇 2023-01-27 10:00
下一篇 2023-01-27

相关推荐

  • mysql 使用 limit ,从指定条数读取完,-1失效「建议收藏」

    mysql 使用 limit ,从指定条数读取完,-1失效「建议收藏」SELECT * FROM `wit_honor` order by `order` limit 15,-1 原因很简单这种写法本身就是错的,虽然它可以在之前的版本中运行(低优先级),新版本的mysq

    2023-01-31
    165
  • 左右序列_个人数据存储方案

    左右序列_个人数据存储方案最近在工作中业务需要,了解了左右值编码的树形结构存储方案,仔细研究了一下,整理了一个笔记分享给大家,如有错误之处望指出。 一、左右值编码 在基于数据库的一般应用中,查询的需求总要大于删除和修改。为了…

    2023-03-09
    153
  • 计算节点时间并标出关键路线_数据未找到当前工作流节点

    计算节点时间并标出关键路线_数据未找到当前工作流节点第1节,关键字 驰骋工作流引擎 流程快速开发平台 workflow ccflow jflow 第1节,计算到达节点设计(方向条件规则) 节点的方向条件,就是节点在发送的时候遇到分支,如何让系统选择业…

    2023-04-13
    156
  • mysql进阶知识_什么是MySQL

    mysql进阶知识_什么是MySQLMYSQL(进阶篇)——一篇文章带你深入掌握MYSQL 我们在上篇文章中已经学习了MYSQL的基本语法和概念 在这篇文章中我们将讲解底层结构和一些新的语法帮助你更好的运用MYSQL 温馨提醒:该文章大

    2023-05-30
    155
  • Python信号量详解

    Python信号量详解随着多进程和多线程编程模式的发展,进程或线程之间的同步和互斥成了程序设计中十分重要的一部分。在Python中,信号量(Semaphore)是一种用于线程同步的工具。本文将会从多个方面对Python信号量进行详细的阐述,并给出相应的代码示例。

    2024-05-23
    61
  • mysql如何插入时返回自动增长的主键「建议收藏」

    mysql如何插入时返回自动增长的主键「建议收藏」
    主键为id

    2023-04-01
    157
  • 分布式 | DBLE 之 SQL 解析[通俗易懂]

    分布式 | DBLE 之 SQL 解析[通俗易懂]作者:路路 热爱技术、乐于分享的技术人,目前主要从事数据库相关技术的研究。 本文来源:原创投稿 *爱可生开源社区出品,原创内容未经授权不得随意使用,转载请联系小编并注明来源。 数据库中间件与数据库有…

    2023-02-22
    155
  • Python字符串格式化输出

    Python字符串格式化输出在Python中,字符串格式化是一种非常重要的操作。通过格式化字符串,我们可以将各种数据类型以特定的格式输出到屏幕或文件中。本文将介绍Python中常用的字符串格式化方法,并详细讲解每种方法的使用。

    2024-09-06
    23

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注