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로 환산해야 합니다.


목록 | 입력 | 수정 | 답변 | 삭제