<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>惜分飞 &#187; segment header坏块</title>
	<atom:link href="https://www.xifenfei.com/tag/segment-header%e5%9d%8f%e5%9d%97/feed" rel="self" type="application/rss+xml" />
	<link>https://www.xifenfei.com</link>
	<description>提供7*24专业数据库(Oracle,SQL Server,MySQL,PostgreSQL等)恢复和技术支持@Tel:17813235971</description>
	<lastBuildDate>Thu, 29 Oct 2026 15:31:46 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>通过rowid获取segment header坏块数据</title>
		<link>https://www.xifenfei.com/2013/02/%e9%80%9a%e8%bf%87rowid%e8%8e%b7%e5%8f%96segment-header%e5%9d%8f%e5%9d%97%e6%95%b0%e6%8d%ae.html</link>
		<comments>https://www.xifenfei.com/2013/02/%e9%80%9a%e8%bf%87rowid%e8%8e%b7%e5%8f%96segment-header%e5%9d%8f%e5%9d%97%e6%95%b0%e6%8d%ae.html#comments</comments>
		<pubDate>Tue, 19 Feb 2013 13:29:30 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[Oracle备份恢复]]></category>
		<category><![CDATA[segment header坏块]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=4160</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2013/02/%e9%80%9a%e8%bf%87rowid%e8%8e%b7%e5%8f%96segment-header%e5%9d%8f%e5%9d%97%e6%95%b0%e6%8d%ae.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div id="xifenfeicopyright">
<p>联系：<a href="https://www.xifenfei.com/about_xifenfei" target="_blank">手机/微信(+86 17813235971)   QQ(107644445)</a><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&#038;uin=107644445&#038;site=qq&#038;menu=yes"><img src="https://www.xifenfei.com/wp-content/themes/img/site_qq.jpg" alt="QQ咨询惜分飞" title="QQ咨询惜分飞"/></a></p>
<p>标题：<a href="https://www.xifenfei.com/2013/02/%e9%80%9a%e8%bf%87rowid%e8%8e%b7%e5%8f%96segment-header%e5%9d%8f%e5%9d%97%e6%95%b0%e6%8d%ae.html" target="_blank">通过rowid获取segment header坏块数据</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>在上篇(<a href="//www.xifenfei.com/4152.html" title="table中各种坏块对select/dml操作影响" target="_blank">table中各种坏块对select/dml操作影响</a>)中说到如果segment header异常了，不能通过ctas来获得相关数据，在群的讨论中，EZIO说到可以通过rowid方式来获得相关数据，通过测试证明，确实可以通过该方法获得数据，以后遇到此类错误，大家也不必惊慌.<br />
<strong>创建测试表</strong></p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; create table t_xifenfei
  2  as
  3  select * from dba_objects where object_id is not null;


SQL&gt; alter table t_xifenfei
  2  add constraint PK_t_xifenfei primary key (object_id)
  3  ;

Table altered.

SQL&gt; alter system checkpoint;

System altered.

SQL&gt; select count(*) from chf.t_xifenfei;

  COUNT(*)
----------
     74762

SQL&gt; select header_file,header_block from 
  2  DBA_SEGments where segment_name='T_XIFENFEI' AND OWNER='CHF';

HEADER_FILE HEADER_BLOCK
----------- ------------
          4          170
</pre>
<p><strong>dump block</strong></p>
<pre class="brush: bash; title: ; notranslate">
alter system dump datafile 4 block 170;

Dump of buffer cache at level 4 for tsn=4 rdba=16777386
Block dump from disk:
buffer tsn: 4 rdba: 0x010000aa (4/170)
scn: 0x0b8c.3c0092e4 seq: 0x01 flg: 0x04 tail: 0x91e42301
frmt: 0x02 chkval: 0xa531 type: 0x23=PAGETABLE SEGMENT HEADER
</pre>
<p>通过header_block和dump block确定block 170即为PAGETABLE SEGMENT HEADER<br />
<br />
<strong>bbed制造SEGMENT HEADER坏块</strong></p>
<pre class="brush: bash; title: ; notranslate">
BBED&gt; set block 170
        BLOCK#          170

BBED&gt; set offset 8188
        OFFSET          8188

BBED&gt; d
 File: /u01/oracle/oradata/ora11g/users01.dbf (0)
 Block: 170              Offsets: 8188 to 8191           Dba:0x00000000
------------------------------------------------------------------------
 0123e492 

 &lt;32 bytes per line&gt;

BBED&gt; m /x 0123e491
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
 File: /u01/oracle/oradata/ora11g/users01.dbf (0)
 Block: 170              Offsets: 8188 to 8191           Dba:0x00000000
------------------------------------------------------------------------
 0123e491 

 &lt;32 bytes per line&gt;

BBED&gt; sum apply 
Check value for File 0, Block 170:
current = 0xa531, required = 0xa531

BBED&gt; verify
DBVERIFY - Verification starting
FILE = /u01/oracle/oradata/ora11g/users01.dbf
BLOCK = 170

Block 170 is corrupt
Corrupt block relative dba: 0x010000aa (file 0, block 170)
Fractured block found during verification
Data in bad block:
 type: 35 format: 2 rdba: 0x010000aa
 last change scn: 0x0b8c.3c0092e4 seq: 0x1 flg: 0x04
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x91e42301
 check value in block header: 0xa531
 computed block checksum: 0x0


DBVERIFY - Verification complete

Total Blocks Examined         : 1
Total Blocks Processed (Data) : 0
Total Blocks Failing   (Data) : 0
Total Blocks Processed (Index): 0
Total Blocks Failing   (Index): 0
Total Blocks Empty            : 0
Total Blocks Marked Corrupt   : 1
Total Blocks Influx           : 2
Message 531 not found;  product=RDBMS; facility=BBED
</pre>
<p><strong>测试segment header坏块后select操作</strong></p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select * from chf.t_xifenfei;
select * from chf.t_xifenfei
                         *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 4, block # 170)
ORA-01110: data file 4: '/u01/oracle/oradata/ora11g/users01.dbf'

SQL&gt; select /*+index(t PK_T_XIFENFEI)*/  count(rowid) from chf.t_xifenfei t;

COUNT(ROWID)
------------
       74762
</pre>
<p><strong>基于rowid获取segment header 坏块对象数据</strong></p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; create table chf.bad_rows (table_name varchar2(60),
   2 row_id rowid, oracle_error_code number);

Table created.

SQL&gt; DECLARE
  2   TYPE RowIDTab IS TABLE OF ROWID INDEX BY BINARY_INTEGER;
  3   CURSOR c1 IS  select /*+index(t PK_T_XIFENFEI)*/ rowid from chf.t_xifenfei t;
  4   r RowIDTab;
  5   rows  NATURAL := 20000;
  6   bad_rows number := 0 ;
  7   errors number;
  8   error_code number;
  9   myrowid rowid;
 10  BEGIN
 11   OPEN c1;
 12   LOOP
 13     FETCH  c1 BULK COLLECT INTO r LIMIT rows;
 14     EXIT WHEN r.count=0;
 15     BEGIN
 16      FORALL i IN r.FIRST..r.LAST SAVE EXCEPTIONS
 17       insert into chf.t_xifenfei_new
 18       select /*+ ROWID(A) */ *
 19       from chf.t_xifenfei A where rowid = r(i);
 20     EXCEPTION
 21     when OTHERS then
 22      BEGIN
 23       errors := SQL%BULK_EXCEPTIONS.COUNT;
 24       FOR err1 IN 1..errors LOOP
 25           error_code := SQL%BULK_EXCEPTIONS(err1).ERROR_CODE;
 26           myrowid := r(SQL%BULK_EXCEPTIONS(err1).ERROR_INDEX);
 27           bad_rows := bad_rows + 1;
 28           insert into chf.bad_rows values('chf.t_xifenfei',myrowid, error_code);
 29       END LOOP;
 30       END;
 31     END;
 32    commit;
 33   END LOOP;
 34   commit;
 35   CLOSE c1;
 36   dbms_output.put_line('Total Bad Rows: '||bad_rows);
 37  END;
 38  /
Total Bad Rows: 0

PL/SQL procedure successfully completed.

SQL&gt; select count(*) from chf.t_xifenfei_new;

  COUNT(*)
----------
     74762
</pre>
<p>通过上面pl/sql，基于rowid成功获得segment header 异常对象中的所有数据记录.如果没有主键的表出现该问题,可以参考:<a href="//www.xifenfei.com/3898.html" title="使用plsql抢救数据" target="_blank">使用plsql抢救数据</a></p>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2013/02/table%e4%b8%ad%e5%90%84%e7%a7%8d%e5%9d%8f%e5%9d%97%e5%af%b9selectdml%e6%93%8d%e4%bd%9c%e5%bd%b1%e5%93%8d.html" rel="bookmark" class="crp_title">table中各种坏块对select/dml操作影响</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2013/02/table%e4%b8%ad%e5%90%84%e7%a7%8d%e7%b1%bb%e5%9e%8bblock%e5%9d%8f%e5%9d%97%e6%98%af%e5%90%a6%e8%83%bd%e8%a2%ab%e8%b7%b3%e8%bf%87.html" rel="bookmark" class="crp_title">table中各种类型block坏块是否能被跳过</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2013/02/rman%e5%88%b6%e9%80%a0%e5%9d%8f%e5%9d%97bbed%e4%bf%ae%e5%a4%8d%e5%9d%8f%e5%9d%97.html" rel="bookmark" class="crp_title">rman制造坏块,bbed修复坏块</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/09/%e4%bd%bf%e7%94%a8plsql%e6%8a%a2%e6%95%91%e6%95%b0%e6%8d%ae.html" rel="bookmark" class="crp_title">使用plsql抢救数据</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/08/bbed-%e5%88%a0%e9%99%a4-cluster-table-%e8%ae%b0%e5%bd%95.html" rel="bookmark" class="crp_title">bbed 删除 cluster table 记录</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/08/%e5%88%a9%e7%94%a8bbed%e6%89%be%e5%9b%9ebbed%e6%9b%b4%e6%96%b0%e5%89%8d%e5%80%bc.html" rel="bookmark" class="crp_title">利用bbed找回ORACLE更新前值</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/09/%e6%a8%a1%e6%8b%9f%e6%99%ae%e9%80%9aora-08103%e5%b9%b6%e8%a7%a3%e5%86%b3.html" rel="bookmark" class="crp_title">模拟普通ORA-08103并解决</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/09/%e5%81%87%e5%9d%8f%e5%9d%97%e5%bc%95%e8%b5%b7%e6%81%90%e6%85%8c.html" rel="bookmark" class="crp_title">假坏块引起恐慌</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2022/04/segment-header-ora-1578.html" rel="bookmark" class="crp_title">segment header异常对象删除处理</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2023/09/bbed-ora-1578.html" rel="bookmark" class="crp_title">bbed解决ORA-01578</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/05/bbed-%e6%89%be%e5%9b%9e%e8%a2%ab%e5%88%a0%e9%99%a4%e6%95%b0%e6%8d%ae.html" rel="bookmark" class="crp_title">bbed 找回被删除数据</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/10/recover%e9%81%87%e5%88%b0%e5%9d%8f%e5%9d%97%e5%a4%84%e7%90%86%e6%9c%ac%e8%b4%a8%e6%8e%a2%e8%ae%a8.html" rel="bookmark" class="crp_title">recover遇到坏块处理本质探讨</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2013/02/%e9%80%9a%e8%bf%87rowid%e8%8e%b7%e5%8f%96segment-header%e5%9d%8f%e5%9d%97%e6%95%b0%e6%8d%ae.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
