Resize Oracle Datafile的脚本
发布时间:2020-12-12 14:35:48 所属栏目:百科 来源:网络整理
导读:转自惜总文章:http://ask.orasos.com/thread-11-1-1.html set verify offcolumn file_name format a50 word_wrappedcolumn smallest format 999,990 heading "Smallest|Size|Poss."column currsize format 999,990 heading "Current|Size"column savings for
转自惜总文章:http://ask.orasos.com/thread-11-1-1.html 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 a75 word_wrapped select 'alter database datafile '''||file_name||''' resize ' || ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) || 'm;' cmd from dba_data_files a,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 请注意:以上脚本针对如下情况,不能回收全部的空间: 比如一个10个GB的datafile,已经使用第2GB 和第9GB,从表空间使用率的角度看,Free空间是8GB,用以上脚本仅仅能回收的空间肯定是远远小于8GB. 因为,resize的过程只是缩小Datafile的大小,resize并不负责移动数据库对象(table 或者index) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |