Oracle

查找 Oracle BIN$ 段的範圍

  • November 12, 2017

我正在尋找有關資源回收筒範圍的資訊。

刪除表時,其段被重命名為“BIN$…”系統生成的名稱,並且範圍被隱藏。

這些範圍仍然會阻止我縮小數據文件(或表空間)嗎?如果是這樣,我想在腳本中說明它們。

目前我正在使用受 AskTom 的 maxshrink.sql 啟發的查詢:

select tbs.TABLESPACE_NAME, df.FILE_NAME,
   round(MAX(e.BLOCKS+e.BLOCK_ID+1)*tbs.BLOCK_SIZE/1024/1024,2) "MinMB",
   round(MAX(df.BYTES)/1024/1024,2) "FileMB"
 from DBA_TABLESPACES tbs
 LEFT JOIN DBA_DATA_FILES df on tbs.TABLESPACE_NAME = df.TABLESPACE_NAME
 LEFT JOIN DBA_EXTENTS e on df.FILE_ID = e.FILE_ID AND df.RELATIVE_FNO = e.RELATIVE_FNO
 -- WHERE
 --   tbs.TABLESPACE_NAME like 'MY%'
 GROUP BY df.FILE_ID, df.RELATIVE_FNO, tbs.TABLESPACE_NAME, tbs.BLOCK_SIZE, df.FILE_NAME
 ORDER BY 1,2;

更新:最初我的問題還問我為什麼在 12.2 中不再看到由 Flashback Drop Table 創建的“BIN$”段。然而,這對我來說是一個錯誤,我的測試表根本沒有開始的段。

create table bp.t1 as select * from dba_users;
drop table bp.t1;

select owner, object_name, original_name from dba_recyclebin where owner = 'BP';

OWNER OBJECT_NAME                     ORIGINAL_NAME
----- ------------------------------- -------------
BP    BIN$XY0E/EKVFyXgU0cBqMCr3Q==$0  T1           

select * from dba_extents where owner = 'BP';

no rows selected

DBA_EXTENTS從過濾器丟棄對象的定義的相關部分中刪除(註釋掉)過濾器:

select
 ds.owner, ds.segment_name, ds.partition_name, ds.segment_type,
 ds.tablespace_name,
 e.ktfbueextno, f.file#, e.ktfbuebno,
 e.ktfbueblks * ds.blocksize, e.ktfbueblks, e.ktfbuefno
from
 sys.sys_dba_segs ds, sys.x$ktfbue e, sys.file$ f
where
 e.ktfbuesegfno = ds.relative_fno
 and e.ktfbuesegbno = ds.header_block
 and e.ktfbuesegtsn = ds.tablespace_id
 and ds.tablespace_id = f.ts#
 and e.ktfbuefno = f.relfile#
 and bitand(NVL(ds.segment_flags, 0), 1) = 1
 --and bitand(NVL(ds.segment_flags,0), 65536) = 0
 and ds.owner = 'BP';

OWNER SEGMENT_NAME                   PARTITION_NAME SEGMENT_TYPE       TABLESPACE_NAME KTFBUEEXTNO      FILE#  KTFBUEBNO E.KTFBUEBLKS*DS.BLOCKSIZE KTFBUEBLKS  KTFBUEFNO
----- ------------------------------ -------------- ------------------ --------------- ----------- ---------- ---------- ------------------------- ---------- ----------
BP    BIN$XY0E/EKVFyXgU0cBqMCr3Q==$0                TABLE              USERS                     0          4        128                     65536          8          4

引用自:https://dba.stackexchange.com/questions/190494