ITPub博客

首页 > Linux操作系统 > Linux操作系统 > datafile resize 脚本

datafile resize 脚本

原创 Linux操作系统 作者:is.x 时间:2011-06-12 11:53:22 0 删除 编辑

网上看到的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

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/20750200/viewspace-697698/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-04-27

  • 博文量
    73
  • 访问量
    294002