Navigation Menu

Skip to content

Commit

Permalink
Update procedure to recreate table
Browse files Browse the repository at this point in the history
  • Loading branch information
kenhys committed Jul 31, 2019
1 parent a48f8d5 commit 5c56680
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion en/_posts/2019-07-30-mroonga-9.05.md
Expand Up @@ -71,7 +71,13 @@ ERROR 1062 (23000): Duplicate entry '10-100' for key 'source_id'
In above example, old index entry was not deleted correctly, therefore duplicated key error was occurred.

In this case, you must recreate an target table because unique index may have garbage entries.
We recommend to recreate an target table with dump and restore, or execute `ALTER TABLE (TABLE_NAME) FORCE`.
We recommend to recreate an target table with dump and restore, or execute the following queries.

```sql
ALTER TABLE (TABLE_NAME) DISABLE KEYS;
ALTER TABLE (TABLE_NAME) FORCE;
ALTER TABLE (TABLE_NAME) ENABLE KEYS;
```

### Conclusion

Expand Down
8 changes: 7 additions & 1 deletion ja/_posts/2019-07-30-mroonga-9.05.md
Expand Up @@ -73,7 +73,13 @@ ERROR 1062 (23000): Duplicate entry '10-100' for key 'source_id'
上記のようなケースで、古いインデックスのエントリが削除されず、キーの重複が発生してしまっていました。

冒頭でも述べましたが、すでにユニークインデックスを作っている人はテーブルを作り直す必要があります。
テーブルを作り直すには、ダンプ・リストアするか、`ALTER TABLE (ユニークインデックスを作ったテーブル} FORCE` を実行してください。
テーブルを作り直すには、ダンプ・リストアするか、以下の手順を実行してください。

```sql
ALTER TABLE (ユニークインデックスを作ったテーブル) DISABLE KEYS;
ALTER TABLE (ユニークインデックスを作ったテーブル) FORCE;
ALTER TABLE (ユニークインデックスを作ったテーブル) ENABLE KEYS;
```

### おわりに

Expand Down

0 comments on commit 5c56680

Please sign in to comment.