01.MySQL

[MySQL]MyISAM 테이블 복구

redkite 2012. 12. 19. 15:42

== SYSIA01 테이블 상태 확인

[sysoper@mysql_test btproworks]$ myisamchk --extend-check SYSIA01

Checking MyISAM file: SYSIA01

Data records: 14981 Deleted blocks: 0

myisamchk: warning: 1 client is using or hasn't closed the table properly

- check file-size

- check record delete-chain

- check key delete-chain

- check index reference

- check records and index references

MyISAM-table 'SYSIA01' is usable but should be fixed

== 테이블 복구

[sysoper@mysql_test btproworks]$ myisamchk -r SYSIA01

-- recovering (with keycache) MyISAM-table 'SYSIA01'

Data records: 14981

== 테이블 조회

mysql> select * from SYSIA01 limit 1;

+--------------+--------+------------+---------+-------------+------------+---------+----------+-----------+-----------+----------------+--------------+-----------+

| nComponentID | nStage | nProjectID | sTypeID | sCategoryID | sProgramID | nStatus | sVersion | sFileName | sFilePath | sComponentName | sDescription | nFileSize |

+--------------+--------+------------+---------+-------------+------------+---------+----------+-----------+-----------+----------------+--------------+-----------+

| 1 | 0 | 1 | A08 | | | 1 | 2 | | | | | NULL |

+--------------+--------+------------+---------+-------------+------------+---------+----------+-----------+-----------+----------------+--------------+-----------+

1 row in set (0.00 sec)

ERROR 1194 (HY000); Table 'guess' is marked as crashed and should be repaired

 

이는 데이터가 깨져서 복구돼야 된다는 것을 의미한다. 이럴 때는 다음과 같은 방법으로 데이터를 복구한다.

 

check table SYSDB10;

 

그러면 에러의 내용을 표시한다. 그리고 다음과 같이 에러를 복구한다.

 

repair table SYSDB10;

 

그러면 데이터가 수정되면서 그 수정된 내용이 무엇인지 출력될 것이다.

 

명렁어 자체가 자연어에 유사해서 더 이상의 설명이 필요없을 것이다.