How to convert H2Database database file to MySQL database .sql file?

后端 未结 5 1438
你的背包
你的背包 2021-02-01 10:41

I have some data in H2Database file and I want to convert it to MySQL .sql database file. What are the methods I can follow?

5条回答
  •  再見小時候
    2021-02-01 11:02

    In answer to Thomas Mueller, SquirrelSQL worked fine for me. Here is the procedure for Windows to convert a H2 database:

    1. Go to "drivers list", where everything is red by default.

    2. Select "H2" driver, and specify the full path to "h2-1.3.173.jar" (for example) in "Extra Class Path". The H2 driver should display a blue check in the list.

    3. Select your target driver (PostgreSQL, MySQL), and do the same, for example for PostgreSQL, specify the full path to "postgresql-9.4-1201.jdbc41.jar" in Extra Class Path.

    4. Go to "Aliases", then click on "+" for H2 : configure your JDBC chain, for example copy/paste the jdbc chain you obtain when you launch H2, and do the same for your target database: click on "+", configure and "test".

    5. When you double click on your alias, you should see everything inside your database in a new Tab. Go to the tables in source database, do a multi-select on all your tables and do a right-click : "Copy Table".

    6. Go to your target database from Alias, and do a "Paste Table". When all tables are copied altogether, the foreign key references are also generated.

    7. Check your primary keys : from H2 to PostgreSQL, I lost the Primary Key constraints, and the auto-increment capability. You could also rename columns and tables by a right click : "refactor". I used it to rename reserved words columns after full copy, by disabling name check in options.

      This worked well for me.

提交回复
热议问题