Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How in H2DB get sql dump like in MySql?

Tags:

sql

dump

h2

I have H2DB database which stores data in files. I have 3 files: test.18.log.db, test.data.db, and test.index.db.

I want get SQL dump file like when I use mysqldump. Is it possible?

like image 798
palych063 Avatar asked Jul 15 '10 14:07

palych063


People also ask

How do I backup my H2 database?

Use the following command for the same. BACKUP TO 'backup. zip'; On executing the above command, you will get the backup.


2 Answers

Yes, there are multiple solutions. One is to run the SCRIPT SQL statement:

SCRIPT TO 'fileName' 

Another is to use the Script tool:

java org.h2.tools.Script -url <url> -user <user> -password <password> 

Then, there are also the RUNSCRIPT statement and RunScript tool.

By the way, you should consider upgrading to a more recent version of H2. With newer versions, the two files .data.db and .index.db are combined in to a .h2.db file.

like image 147
Thomas Mueller Avatar answered Sep 23 '22 11:09

Thomas Mueller


If you want to get schema and data, you can use

SCRIPT TO 'dump.sql'; 

If you want to get only schema, you can use

SCRIPT SIMPLE TO 'dump.txt'; 
like image 34
ahmeticat Avatar answered Sep 22 '22 11:09

ahmeticat