Oracle缩小表空间大小

1、碎片整理
合并表空间的碎片增加表空间的连续性
alter tablespace POSP_DATA coalesce;

2、缩小表空间大小
大小不能小于数据文件中的所处的最大位置
alter database datafile '/oradata/posp/posp_data16.dbf' RESIZE 2048M;

3、查询表空间使用率
select a.tablespace_name as tablespace, total, free,(total-free) as usage from
(select tablespace_name, sum(bytes)/1024/1024 as total from dba_data_files group by tablespace_name) a,
(select tablespace_name, sum(bytes)/1024/1024 as free from dba_free_space group by tablespace_name) b
where a.tablespace_name = b.tablespace_name;

TABLESPACE TOTAL FREE USAGE
--------------------
SYSAUX 980 48.6875 931.3125
UNDOTBS1 250 218.75 31.25
POSP_DATA 32768 31643.875 1124.125
USERS 5 3.6875 1.3125
SYSTEM 1730 7.1875 1722.8125
POSP_IDX 4096 3999.8125 96.1875