export h2 to CSV

427 views
Skip to first unread message

Giovanni Martinez

unread,
Feb 7, 2019, 1:27:26 PM2/7/19
to H2 Database
I have an H2 database that I need to access. My goal is,first,  from the command line, going into the database and check what I have. Second, export all the data to CSV. How can I do that?

Giovanni Martinez

unread,
Feb 7, 2019, 3:35:48 PM2/7/19
to H2 Database
I connected to the database using PyCharm Pro. I connected to the database using the following connection string: jdbc:h2:file:/var/lib/rundeck/data/rundeckdb.mv.db. But I still don't see my schema.

Evgenij Ryazanov

unread,
Feb 7, 2019, 11:37:35 PM2/7/19
to H2 Database
Hello.

You can use CSVWRITE function to export some table or query results to CSV:
http://h2database.com/html/functions.html#csvwrite

There in so way to export the whole database to CSV, because database may contain multiple tables and other objects.
But you can use SCRIPT TO command to export everything to SQL if you need it:

Giovanni Martinez

unread,
Feb 12, 2019, 1:35:48 PM2/12/19
to H2 Database
thank you
Reply all
Reply to author
Forward
0 new messages