使用连续空闲块调整 Oracle 表空间大小

Oracle tablespace resizing with consecutive free blocks

我经常在我们的 Oracle 实例 (11g) 中减少 tablespace。

使用以下脚本(来自系统用户)我可以准确地知道为每个对象分配的 space tablespace(例如 MY_TABLESPACE):

select
    tablespace_name, file_id, block_id,
    block_id + blocks - 1  end_block, owner,
    segment_name, partition_name, segment_type
from
    dba_extents
where 1=1
and   tablespace_name = 'MY_TABLESPACE'
union all
select
    tablespace_name, file_id, block_id,
    block_id + blocks - 1   end_block,
    'free' owner, 'free' segment_name,
    null partition_name, null segment_type
from
    dba_free_space
where 1=1
and   tablespace_name = 'MY_TABLESPACE'
order by
    file_id desc,
    block_id desc;

我尝试了以下奇怪的事情,我无法调整大小的连续空闲块:

Consecutive free blocks

这意味着 我们有 19095 个无法调整大小的空闲块(约 150 Mb)

为了避免 tablespace 的完全删除和重新创建,有人可以帮助我吗?

您如何尝试 "resize" tablespace?

看起来您需要做的就是 运行 Segment Advisor 的 Tablepsace level Shrink 选项,它将为您完成收缩并回收 space。

如果您有 OEM,则很容易做到 - 只需 运行 用于您的 tablespace.

的细分顾问

如果您需要脚本来执行此操作,请在此处检查 DBMS_ADVISOR 包用法: https://docs.oracle.com/cd/B28359_01/server.111/b28310/schema003.htm