zoukankan      html  css  js  c++  java
  • 数据库每日空间增量

    -- |----------------------------------------------------------------------------|
    -- | DATABASE : Oracle                                                          |
    -- | FILE     : show_database_increase.sql                                      |
    -- | CLASS    : Database Administration                                         |
    -- | PURPOSE  : This script is listed in the relevant paragraph database        |
    -- | history of the use of space in a snapshot of time change information       |
    -- | This information is not contain undo and temp tablespace                   |
    -- | NOTE     :                                                                 |
    -- +----------------------------------------------------------------------------+

    SET TERMOUT OFF;
    COLUMN current_instance NEW_VALUE current_instance NOPRINT;
    SELECT rpad(instance_name, 17) current_instance FROM v$instance;
    COLUMN USER NEW_VALUE user_name NOPRINT;
    SELECT USER FROM DUAL;
    SET TERMOUT ON;

    PROMPT
    PROMPT +------------------------------------------------------------------------+
    PROMPT | Report   : show_database_increase                                      |
    PROMPT | Instance : &current_instance                                           |
    PROMPT | USER     : &user_name                                                  |
    PROMPT +------------------------------------------------------------------------+


    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
            ORDER BY rtime
            /
  • 相关阅读:
    学习笔记16:残差网络
    学习笔记15:第二种加载数据的方法
    学习笔记14:模型保存
    学习笔记13:微调模型
    学习笔记12:图像数据增强及学习速率衰减
    蚯蚓
    [JSOI] 重要的城市
    正则表达式
    加分二叉树
    选择客栈
  • 原文地址:https://www.cnblogs.com/laverne/p/12674668.html
Copyright © 2011-2022 走看看