How do I import data into an in-memory database?

Is there a way to import data to databases like MS SQL, MySQL to in-memory databases like HSQLDB, H2, etc.?

+1


a source to share


8 answers


H2 maintains a custom database url that initialized the database from a SQL script file :

"jdbc:h2:mem;INIT=RUNSCRIPT FROM '~/create.sql'"

      



HSQLDB and Apache Derby do not support such a feature as far as I know.

+2


a source


I think you need to do

  • query data from MS SQL

  • import data into database using API



Either SQL expressions or DB related APIs

+1


a source


In Hibernate: adding import.sql to the classpath works fine, hbm2dll checks if the file exists and executes it. The only information is that each sql command is on one line, otherwise it won't be able to execute

+1


a source


You can dump the data as SQL INSERT statements and then read it.

You can read a time object (like a structure) and then write back to the internal db.

0


a source


Take a look at the free "universal database converter" http://eva-3-universal-database-converter-udc.optadat-com.qarchive.org/ - it claims to support MySQL, MS-SQL and HSQLDB, among others.

0


a source


It really depends on how you think. Is there a tool that can do this automatically without programming? May be.

Do you want to develop it? Then find out if your favorite language supports both database engines (standard and in memory), and if so, just write a script that does it. Process everything in chunks (fetch n lines at a time, then insert them, repeat). How big is the piece? It's up to you, try different sizes (say 100, 500, 1k, etc.), see which one works best on your hardware, fine tuning for the sweet spot.

If your favorite language, on the other hand, doesn't support both of them, try using something that does.

0


a source


You can use dbunit to dump the database to xml files and import it back to another rdbms.

0


a source


Recent versions of HSQLDB allow you to open CSV (Comma Separated Values) or other delimiter data file as a TEXT TABLE in HSQLDB, even with mem: databases, which can then be copied to other tables.

As others have noted, there are also supported and supported third party tools for this purpose.

0


a source







All Articles