zoukankan      html  css  js  c++  java
  • Oracle计算datafile可以resize收缩的空间

    计算datafile可以resize收缩的空间.
    col name for a40
    col resizecmd for a80

    select a.file#,a.name,a.bytes/1024/1024 CurrentMB,
           ceil(HWM * a.block_size)/1024/1024 ResizeTo,
           (a.bytes - HWM * a.block_size)/1024/1024 ReleaseMB,
           'alter database datafile '''||a.name||''' resize '||
           ceil(HWM * a.block_size/1024/1024) || 'M;' ResizeCMD
    from v$datafile a,
         (select file_id,max(block_id+blocks-1) HWM
           from dba_extents
           group by file_id) b
    where a.file# = b.file_id(+)
    and (a.bytes - HWM *block_size)>0
    order by 5

    如果只是想对某个表个间的datafile resize,可采用:
    select a.file#,a.name,a.bytes/1024/1024 CurrentMB,
           ceil(HWM * a.block_size)/1024/1024 ResizeTo,
           (a.bytes - HWM * a.block_size)/1024/1024 ReleaseMB,
           'alter database datafile '''||a.name||''' resize '||
           ceil(HWM * a.block_size/1024/1024) || 'M;' ResizeCMD
    from v$datafile a,
         (select file_id,max(block_id+blocks-1) HWM
           from dba_extents where file_id in 
                  (select b.file#  From v$tablespace a ,v$datafile b
                    where a.ts#=b.ts# and a.name='MP2000')
           group by file_id) b
    where a.file# = b.file_id(+)
    and (a.bytes - HWM *block_size)>0
    order by 5


    计划tempfile可以resize的空间.on apply that have only one tempfile

    select 'alter database tempfile '''||a.name ||''' reize '||b.siz||'M;' from v$tempfile a,
         (select tmsize.maxblk*bk.value/1024/1024 siz from
             (select nvl(max(segblk#),128) maxblk  from v$sort_usage) tmsize,
             (select value From v$parameter where name = 'db_block_size') bk) b

  • 相关阅读:
    Synchronized 锁 批量重偏向 和批量撤销
    Synchronize 偏向锁,轻量级锁升级和撤销过程,对象头的变化
    JAVA 对象到底有什么
    什么是操作系统虚拟地址
    从C角度看 i = i+ 1本质
    Linux操作系统的三种锁机制
    SpringCloud启动过程中如何完成Nacos服务注册
    Nacos源码一
    JAVA线程的本质
    SpringCloud启动-Nacos服务注册
  • 原文地址:https://www.cnblogs.com/yaoyangding/p/12578987.html
Copyright © 2011-2022 走看看