select /*+ INDEX_FFS() */ rowid , dbms_rowid.ROWID_RELATIVE_FNO(rowid) relative_fno , dbms_rowid.ROWID_BLOCK_NUMBER(rowid) block from where is not null minus select /*+ FULL()*/ rowid , dbms_rowid.ROWID_RELATIVE_FNO(rowid) relative_fno , dbms_rowid.ROWID_BLOCK_NUMBER(rowid) block from ;
实例:
select /*+ INDEX_FFS(TEST I_TEST) */ rowid , dbms_rowid.ROWID_RELATIVE_FNO(rowid) relative_fno , dbms_rowid.ROWID_BLOCK_NUMBER(rowid) block from test where c2 is not null minus select /*+ FULL(TEST)*/ rowid , dbms_rowid.ROWID_RELATIVE_FNO(rowid) relative_fno , dbms_rowid.ROWID_BLOCK_NUMBER(rowid) block from test;
使用下面PLSQ中的索引,可以将全表扫描丢失的行存储到另一张表中:
drop table test_copy;
create table test_copy as select * from test where 1=2;
declare cursor missing_rows is select /*+ INDEX_FFS(TEST I_TEST) */ rowid rid from test where c2 is not null minus select /*+ FULL(TEST)*/ rowid rid from test; begin for i in missing_rows loop insert into TEST_COPY select /*+ ROWID(TEST) */ * from TEST where rowid = i.rid; end loop; end; /
select header_file, header_block, tablespace_name from dba_segments
where owner = upper('&table_owner') and segment_name = upper('&table_name');
alter system dump datafile &header_file block &header_block;
trace文件用来明确HWM。
@ Example from a block dump not using ASSM (Automatic Segment Space Management): @ @ Extent Control Header @ ----------------------------------------------------------------- @ Extent Header:: spare1: 0 spare2: 0 #extents: 4 #blocks: 31 @ last map 0x00000000 #maps: 0 offset: 4128 @ Highwater:: 0x014000d6 ext#: 3 blk#: 5 ext size: 8 @ @ So, HWM is located at RDBA 0x014000d6 in extent_id=5 and block#=5 in that extent.
)*/ rowid rid , dbms_rowid.ROWID_RELATIVE_FNO(rowid) relative_fno , dbms_rowid.ROWID_BLOCK_NUMBER(rowid) block from
) a , dba_extents e where a.relative_fno=e.relative_fno and e.tablespace_name = upper('&tablespace_name') and v.ts#=&tablespace_number and (a.block between e.block_id and e.block_id+blocks-1);