缩小数据文件
- 查看数据文件能缩小的最小值
- ceil 函数:返回大于或等于 n 的最小整数
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(+) order by savings desc
/
- 缩小数据文件的大小
SQL> alter database datafile '/oracle/app/oradata/ORCL/data01.dbf' resize 3800M;
Database altered.
- 如果低于HWM,则会出现以下报错
SQL> alter database datafile '/oracle/app/oradata/ORCL/data01.dbf' resize 3700M;
alter database datafile '/oracle/app/oradata/ORCL/data01.dbf' resize 3700M
*
ERROR at line 1:
ORA-03297: file contains used data beyond requested RESIZE value
标签:1024,数据文件,column,ceil,blksize,file,Oracle,缩小,id
From: https://blog.51cto.com/u_13482808/7334996