# H2数据库异常修复

用H2自带修改工具。

先从[http://www.h2database.com/html/download.htm](http://www.h2database.com/html/download.html)下载，并安装window版H2

![](/files/-Lu70X-bI7zcaeuaX-x3)

一、将损坏的数据库X.h2.db移动到h2的bin目录下，如\h2\bin，

二、然后，进入cmd,后进入对应目录输入：

java -cp h2-1.4.200.jar org.h2.tools.Recover &#x20;

![](/files/-Lu6uQoh9ThzqgYkTJEV)

&#x20;于是，可以看到bin目录下生成了一个SQL文件X.h2.sql。

三、利用生成sql语句文档内容，再生成数据库X2

C:\Program Files\H2\bin>java -cp h2-1.4.200.jar org.h2.tools.RunScript -url jdbc

:h2:./X2 -user sa -password o2 -script X.h2.sql

执行命令后，X.h2.sql内容写入到X2.mv.db

![](/files/-Lu6xf-1kGFnJABn88yJ)

![](/files/-Lu6xm9uAJjaLXjC4M2y)

第二种修复方法：java -cp h2-1.4.200.jar org.h2.tools.Script -url jdbc:h2:./X -user sa -password o2 -script ./backup.sql &#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://o2oa.gitbook.io/course/chang-jian-cuo-wu/h2-shu-ju-ku-yi-chang-xiu-fu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
