• 数据库每日空间增量


    -- |----------------------------------------------------------------------------|
    -- | 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
            /
  • 相关阅读:
    ASP.NET Web API 记录请求响应数据到日志的一个方法
    EF删除集中方法对比
    CSS 的优先级机制[总结]
    sql备份命令
    sql两张表关联更新字段
    VSCode隐藏node_modules目录
    C# RSACryptoServiceProvider加密解密签名验签和DESCryptoServic
    模拟退火(转)
    HNOI2006-鬼谷子的钱袋
    HNOI2006-公路修建问题(二分答案+并查集)
  • 原文地址:https://www.cnblogs.com/laverne/p/12674668.html
Copyright © 2020-2023  润新知