ORA-1578ÀÌ ºí·°¿¡¼­ ¹ß»ýÇÑ °æ¿ì
ÀÛ¼ºÀÚ °ü¸®ÀÚ ÀÛ¼º½Ã°£ 2008-01-10 13:27:17
 

ORA-1578ÀÌ ºí·°¿¡¼­ ¹ß»ýÇÑ °æ¿ì 


ÀϹÝÀûÀ¸·Î ORA-1578 : ORACLE data block corrupted (file # num, block # num)Àº ÇØ´ç objects¸¦
dropÇϰí recreateÇÏ¿© ó¸® ÇÒ ¼ö ÀÖÀ¾´Ï´Ù. ÇÏÁö¸¸, backupÀÌ ¾ÈµÇ¾î Àְųª µÇ¾î ÀÖ´õ¶óµµ ½ÃÁ¡¿¡
¹®Á¦°¡ »ý±â¸é, ´çȲÇÒ ¼ö ¹Û¿¡ ¾ø½À´Ï´Ù. µû¶ó¼­, ¼Õ»óµÈ db block¸¸À» Á¦¿ÜÇÑ ´Ù¸¥ blockµéÀ»
recoverÇÏ´Â ¹æ¹ýÀ» ¾Ë·Á µå¸³´Ï´Ù.

(1) ¼Õ»óµÈ table°ú ¶È°°Àº specÀÇ new table»ý¼º

(2) ¾Æ·¡ÀÇ pl/sql ½ÇÇà
/*
** This program uses a cursor to select the ROWID from INDEX 
** for the corrupted table. And insert the all of the normal rows
** into the new table.
**
*/

DECLARE
  CURSOR c1 is
SELECT ROWID FROM corrupted_table
WHERE  indexed_column > smallest_value_of_the_indexes
AND    SUBSTR(ROWID,1,8) != '000005DA';

/* Here, the value of '000005DA' is displayed in decimal
  when ORA-1578 error happens. */

  rowid_value    CHAR(18);
  count_value    NUMBER;
BEGIN
  OPEN c1;

  FOR i IN 1..total_number_of_the_rows_from_corrupted_table LOOP
FETCH c1 INTO rowid_value;
EXIT WHEN c1%NOTFOUND;
INSERT INTO new_table
SELECT * FROM corrupted_table WHERE ROWID = rowid_value;
count_value := count_value + 1;
IF count_value = 10000 THEN /* Let's think commit per 10000 rows */
          COMMIT;
  count_value := 0;
      END-IF;
  END LOOP;

  CLOSE c1;
END;
/

(3) new tableÀÇ data°Ç¼ö µî È®ÀÎ ÈÄ¿¡  ±âÁ¸ tableÀ» ´Ù¸¥ À̸§À¸·Î renameÇÑ ÈÄ new tableÀ» original
table nameÀ¸·Î rename
SQL> rename corrupted_table to table_save;
SQL> rename new_table to corrupted_table;

(4) ÇÊ¿äÇÑ index»ý¼ºÀ̳ª constraint enable

(5) ¼Õ»óµÈ row¿¡ ´ëÇÑ ³»¿ëÀº,
ÃÖ¼ÒÇÑ primary key³ª indexed columns¿¡ ´ëÇÑ ³»¿ëÀ»
SQL> spool chk.log
  SQL> select rowid,indexed_column1,indexed_column2,indexed_column3...
      from corrupted_table
      where indexed_column1 > smallest_value_of_the_index;
  SQL> spool off
¸¦ ÅëÇÏ¿© chk.log¿¡ ÀúÀå ÈÄ,
SQL> select count(*) from corrupted_table;
ȤÀº
  table exportµîÀ» ÅëÇÏ¿© È®ÀÎµÈ rowidÀÇ block number¸¦ ºñ±³ÇÏ¿© º¸¸é µË´Ï´Ù.
  ÁÖÀÇ> ¿©±â¿¡¼­ ORA-1578°ú µ¿¹ÝµÇ´Â block number´Â decimalÀÌ´Ï, hexa·Î ȯ»êÇØ¾ß ÇÕ´Ï´Ù.


¸ñ·Ï | ÀÔ·Â | ¼öÁ¤ | ´äº¯ | »èÁ¦