码迷,mamicode.com
首页 > 数据库 > 详细

重设数据文件大小sql语句

时间:2018-08-03 00:53:57      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:current   value   col   group by   nvl   extent   set   group   bsp   

set verify off
column file_name format a50 word_wrapped
column smallest format 999,990 heading "Smallest|Size|Poss."
column currsize format 999,990 heading "Current|Size"
column savings format 999,990 heading "Poss.|Savings"
break on report
compute sum of savings on report
 
column value new_val blksize
select value from v$parameter where name = ‘db_block_size‘
 
select file_name,
       ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) smallest,
       ceil( blocks*&&blksize/1024/1024) currsize,
       ceil( blocks*&&blksize/1024/1024) -
       ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) savings
from dba_data_files a,
     ( select file_id, max(block_id+blocks-1) hwm
         from dba_extents
        group by file_id ) b
where a.file_id = b.file_id(+)
 
column cmd format a120 word_wrapped
 
select ‘alter database datafile ‘‘‘||file_name||‘‘‘ resize ‘ ||
       ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) || ‘m;‘ cmd
from dba_data_files a,
     ( select file_id, max(block_id+blocks-1) hwm
         from dba_extents
        group by file_id ) b
where a.file_id = b.file_id(+)
  and ceil( blocks*&&blksize/1024/1024) -
      ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) > 0;

重设数据文件大小sql语句

标签:current   value   col   group by   nvl   extent   set   group   bsp   

原文地址:https://www.cnblogs.com/liang545621/p/9410684.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!