问题
Has HSQLDB some mechanism for saving in-memory data to file?
As I know after the server is shutted down, all in-memory data become unaccessible. So I want to save all in-memory data to file. Unfortunately I can't use BACKUP mechanism, because it can't be applied for in-memory data.
回答1:
HSQLDB databases are of different types. The all-in-memory databases do not store the data to disk. These databases have URLs in the form jdbc:hsqldb:mem:<name>
.
If your database URL is in the form jdbc:hsqldb:file:<file path>
and your tables are the default MEMORY tables, the data is all in memory but the changes are written to a set of disk files.
With all types of database, including all_in_memory, you can use the SQL statement SCRIPT <file path>
to save the full database to a file. If you save the data to a file with the .script
extension, you can open the file as a file database.
When you run a server, the URL's are used without the jdbc:hsqldb
prefix, for example server.database.0=file:C:/myfile
See the guide here http://hsqldb.org/doc/2.0/guide/running-chapt.html#running_db-sect
回答2:
There is an SQL command for that. Try this:
SCRIPT '/tmp/data.sql'
See here for details.
来源:https://stackoverflow.com/questions/6734158/has-hsqldb-some-mechanism-to-save-in-memory-data-to-file