恢复H2数据库 [英] Restore h2 database

查看:144
本文介绍了恢复H2数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将h2数据库用于基于桌面的应用程序(使用swing).我还备份了该文件,并以".h2.db"扩展名将其存储在我的文件系统中.这不是可读文件.那么如何恢复我的h2备份文件?

I have used the h2 database for a Desktop based application (using swing). I also backed it up and stored it in my file system with the ".h2.db" extension. This is not a readable file. So how can I restore my h2 backup file?

推荐答案

建议使用特定工具创建一个ZIP文件.应当也可以在复制的文件上使用该工具:

It's recommended to create a ZIP file using a specific tool. It should be possible to use the tool on the copied file as well:

备份数据库的推荐方法是创建压缩的SQL脚本文件.这将产生一个小型的,易于阅读的数据库版本无关的备份.创建脚本还将验证数据库文件的校验和.脚本工具的运行方式如下:
java org.h2.tools.Script -url jdbc:h2:〜/test -user sa -script test.zip -options压缩zip

The recommended way to backup a database is to create a compressed SQL script file. This will result in a small, human readable, and database version independent backup. Creating the script will also verify the checksums of the database file. The Script tool is ran as follows:
java org.h2.tools.Script -url jdbc:h2:~/test -user sa -script test.zip -options compression zip

然后可以使用ZIP文件还原数据库:

The ZIP file can then be used to restore the DB:

要从SQL脚本文件还原数据库,可以使用RunScript工具:
java org.h2.tools.RunScript -url jdbc:h2:〜/test -user sa -scripttest.zip-选项压缩zip

To restore a database from a SQL script file, you can use the RunScript tool:
java org.h2.tools.RunScript -url jdbc:h2:~/test -user sa -script test.zip -options compression zip

http://h2database.com/html/tutorial.html#upgrade_backup_restore

这篇关于恢复H2数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆