OS:
Oracle Linux Server release 5.7
DB:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
收缩表空间大小,最小必须是该表空间目前最大块段的大小
查看YOON表空间最大的block_id:
SQL> select max(block_id) from dba_extents where tablespace_name='YOON';
MAX(BLOCK_ID)
-------------
401536
查看数据库的block大小:
SQL> show parameter db_block_size;
NAME TYPE VALUE
------------------------------------ ---------- ------------------------------
db_block_size integer 8192
计算目前最大的块所占用的表空间:
SQL> select 401536*8192/1024/1024 from dual;
401536*8192/1024/1024
---------------------
3137
因此该表空间只能收缩到3G左右:
SQL> select name from v$datafile;
NAME
----------------------------------------
/u01/oracle/oradata/yoon/system01.dbf
/u01/oracle/oradata/yoon/sysaux01.dbf
/u01/oracle/oradata/yoon/undotbs01.dbf
/u01/oracle/oradata/yoondata/users01.dbf
/u01/oracle/oradata/yoon/yoon.dbf
SQL> alter database datafile '/u01/oracle/oradata/yoon/yoon.dbf' resize 4G;
Database altered.