30

I have a stand alone H2 server up and running gathering data. For testing I want to get data out my server into a CSV file. Are there any tools for that?

2
  • 1
    Did you check: h2database.com/html/links.html#tools Commented Jun 20, 2013 at 16:29
  • 2
    H2 has a function to write CSV files. Check CSVWRITE. Commented Jun 21, 2013 at 13:31

3 Answers 3

89

Try CSVWRITE

This is perhaps all that you need:

call CSVWRITE ( 'C:/MyFolder/MyCSV.txt', 'SELECT * FROM MYTABLE' ) 

You need to just run the call (mentioned above) in the browser based client of H2 that you are most likely using.

Further reading: http://www.h2database.com/html/functions.html#csvwrite.

Sign up to request clarification or add additional context in comments.

1 Comment

Probably because the H2 Help command doesn't have any function resembling the term 'export'. I guess you just have to know to look for 'CSV'. See also h2database.com/html/commands.html#script
10

For small data, you can also use script to export any table:

script table <table_name>

1 Comment

Nice answer, but this command produces SQL statements, not a CSV file as requested in the original question.
4

Another way works for me:

script SIMPLE to 'C:\FolderName\FileName.sql' table SCHEMA.TABLENAME;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.