<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	
	>
<channel>
	<title>《使用plsql抢救数据》的评论</title>
	<atom:link 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/feed" rel="self" type="application/rss+xml" />
	<link>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</link>
	<description>提供7*24专业数据库(Oracle,SQL Server,MySQL,PostgreSQL等)恢复和技术支持@Tel:17813235971</description>
	<lastBuildDate>Thu, 11 Dec 2025 02:46:14 +0000</lastBuildDate>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>作者：惜分飞</title>
		<link>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/comment-page-1#comment-1037</link>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
		<pubDate>Sun, 30 Sep 2012 06:50:35 +0000</pubDate>
		<guid isPermaLink="false">https://www.xifenfei.com/?p=3898#comment-1037</guid>
		<description><![CDATA[[sql]
rem RECOVER_OPTION_1

create table bad_rows (row_id rowid, oracle_error_code number);
set serveroutput on

DECLARE
 TYPE RowIDTab IS TABLE OF ROWID INDEX BY BINARY_INTEGER;

 CURSOR c1 IS  select /*+ index(tab1) */ rowid
 from &lt;original table name&gt; tab1
 where &lt;indexed column&gt; is NOT NULL;

 r RowIDTab;
 rows  NATURAL := 20000;
 bad_rows number := 0 ;
 errors number;
 error_code number;
 myrowid rowid;
BEGIN
 OPEN c1;
 LOOP
   FETCH  c1 BULK COLLECT INTO r LIMIT rows;
   EXIT WHEN r.count=0;
   BEGIN
    FORALL i IN r.FIRST..r.LAST SAVE EXCEPTIONS
     insert into &lt;new table name&gt;        
     select /*+ ROWID(A) */ &lt;list of columns from table (ie col1, col2,..)&gt;
     from &lt;original table name&gt; A where rowid = r(i);
   EXCEPTION
   when OTHERS then
    BEGIN
     errors := SQL%BULK_EXCEPTIONS.COUNT;
     FOR err1 IN 1..errors LOOP
       error_code := SQL%BULK_EXCEPTIONS(err1).ERROR_CODE;
       if error_code in (1410, 8103) then
         myrowid := r(SQL%BULK_EXCEPTIONS(err1).ERROR_INDEX);
         bad_rows := bad_rows + 1;
         insert into bad_rows values(myrowid, error_code);
       else
         raise;
       end if;
     END LOOP;
     END;
   END;
  commit;
 END LOOP;
 commit;
 CLOSE c1;
 dbms_output.put_line(&#039;Total Bad Rows: &#039;&#124;&#124;bad_rows);
END;
/
[/sql]]]></description>
		<content:encoded><![CDATA[<pre class="brush: sql; title: ; notranslate">
rem RECOVER_OPTION_1

create table bad_rows (row_id rowid, oracle_error_code number);
set serveroutput on

DECLARE
 TYPE RowIDTab IS TABLE OF ROWID INDEX BY BINARY_INTEGER;

 CURSOR c1 IS  select /*+ index(tab1) */ rowid
 from &lt;original table name&gt; tab1
 where &lt;indexed column&gt; is NOT NULL;

 r RowIDTab;
 rows  NATURAL := 20000;
 bad_rows number := 0 ;
 errors number;
 error_code number;
 myrowid rowid;
BEGIN
 OPEN c1;
 LOOP
   FETCH  c1 BULK COLLECT INTO r LIMIT rows;
   EXIT WHEN r.count=0;
   BEGIN
    FORALL i IN r.FIRST..r.LAST SAVE EXCEPTIONS
     insert into &lt;new table name&gt;        
     select /*+ ROWID(A) */ &lt;list of columns from table (ie col1, col2,..)&gt;
     from &lt;original table name&gt; A where rowid = r(i);
   EXCEPTION
   when OTHERS then
    BEGIN
     errors := SQL%BULK_EXCEPTIONS.COUNT;
     FOR err1 IN 1..errors LOOP
       error_code := SQL%BULK_EXCEPTIONS(err1).ERROR_CODE;
       if error_code in (1410, 8103) then
         myrowid := r(SQL%BULK_EXCEPTIONS(err1).ERROR_INDEX);
         bad_rows := bad_rows + 1;
         insert into bad_rows values(myrowid, error_code);
       else
         raise;
       end if;
     END LOOP;
     END;
   END;
  commit;
 END LOOP;
 commit;
 CLOSE c1;
 dbms_output.put_line('Total Bad Rows: '||bad_rows);
END;
/
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>作者：惜分飞</title>
		<link>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/comment-page-1#comment-1036</link>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
		<pubDate>Sun, 30 Sep 2012 06:50:20 +0000</pubDate>
		<guid isPermaLink="false">https://www.xifenfei.com/?p=3898#comment-1036</guid>
		<description><![CDATA[[sql]
connect / as sysdba 
set serveroutput on 
set concat off         
        
DECLARE  
 nrows number; 
 rid rowid; 
 dobj number; 
 ROWSPERBLOCK number; 
BEGIN 
 ROWSPERBLOCK:=&lt;VALUE CALCULATED IN STEP 1&gt;; 
 nrows:=0; 

 select data_object_id  into dobj  
 from dba_objects  
 where owner = &#039;&amp;&amp;table_owner&#039;  
 and object_name = &#039;&amp;&amp;table_name&#039; 
-- and subobject_name = &#039;&lt;table partition&gt;&#039;  Add this condition if table is partitioned  
 ;

 for i in (select relative_fno, block_id, block_id+blocks-1 totblocks            
           from dba_extents            
           where owner = &#039;&amp;&amp;table_owner&#039;              
             and segment_name = &#039;&amp;&amp;table_name&#039;  
-- and partition_name = &#039;&lt;table partition&gt;&#039; Add this condition if table is partitioned 
-- and file_id != &lt;OFFLINED DATAFILE&gt; This condition is only used if a datafile needs to be skipped due to ORA-376 (A) 
          order by extent_id)  
 loop   
   for br in i.block_id..i.totblocks loop  
    for j in 1..ROWSPERBLOCK loop 
    begin 
      rid := dbms_rowid.ROWID_CREATE(1,dobj,i.relative_fno, br , j-1); 
      insert into &lt;OWNER.NEW_TABLE&gt; (&lt;columns here&gt;)        
      select /*+ ROWID(A) */ &lt;columns here&gt;        
      from &amp;&amp;table_owner.&amp;&amp;table_name A  
      where rowid = rid;          
      if sql%rowcount = 1 then nrows:=nrows+1; end if; 
      if (mod(nrows,10000)=0) then commit; end if; 
    exception when others then null; 
    end; 
    end loop; 
  end loop; 
 end loop; 
 COMMIT;
 dbms_output.put_line(&#039;Total rows: &#039;&#124;&#124;to_char(nrows)); 
END; 
/ 
[/sql]]]></description>
		<content:encoded><![CDATA[<pre class="brush: sql; title: ; notranslate">
connect / as sysdba 
set serveroutput on 
set concat off         
        
DECLARE  
 nrows number; 
 rid rowid; 
 dobj number; 
 ROWSPERBLOCK number; 
BEGIN 
 ROWSPERBLOCK:=&lt;VALUE CALCULATED IN STEP 1&gt;; 
 nrows:=0; 

 select data_object_id  into dobj  
 from dba_objects  
 where owner = '&amp;&amp;table_owner'  
 and object_name = '&amp;&amp;table_name' 
-- and subobject_name = '&lt;table partition&gt;'  Add this condition if table is partitioned  
 ;

 for i in (select relative_fno, block_id, block_id+blocks-1 totblocks            
           from dba_extents            
           where owner = '&amp;&amp;table_owner'              
             and segment_name = '&amp;&amp;table_name'  
-- and partition_name = '&lt;table partition&gt;' Add this condition if table is partitioned 
-- and file_id != &lt;OFFLINED DATAFILE&gt; This condition is only used if a datafile needs to be skipped due to ORA-376 (A) 
          order by extent_id)  
 loop   
   for br in i.block_id..i.totblocks loop  
    for j in 1..ROWSPERBLOCK loop 
    begin 
      rid := dbms_rowid.ROWID_CREATE(1,dobj,i.relative_fno, br , j-1); 
      insert into &lt;OWNER.NEW_TABLE&gt; (&lt;columns here&gt;)        
      select /*+ ROWID(A) */ &lt;columns here&gt;        
      from &amp;&amp;table_owner.&amp;&amp;table_name A  
      where rowid = rid;          
      if sql%rowcount = 1 then nrows:=nrows+1; end if; 
      if (mod(nrows,10000)=0) then commit; end if; 
    exception when others then null; 
    end; 
    end loop; 
  end loop; 
 end loop; 
 COMMIT;
 dbms_output.put_line('Total rows: '||to_char(nrows)); 
END; 
/ 
</pre>
]]></content:encoded>
	</item>
</channel>
</rss>
