如何将H2Database数据库文件转换为MySQL数据库.sql文件? [英] How to convert H2Database database file to MySQL database .sql file?

查看:1232
本文介绍了如何将H2Database数据库文件转换为MySQL数据库.sql文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 H2Database 文件中有一些数据,我想将其转换为MySQL .sql数据库文件.我可以采取哪些方法?

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?

推荐答案

作为对Thomas Mueller的回答,SquirrelSQL对我来说很好. 这是Windows转换H2数据库的过程:

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

  1. 转到驱动程序列表",默认情况下所有内容均为红色.

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

选择"H2"驱动程序,并指定"h2-1.3.173.jar"的完整路径(对于 例如)在附加类路径"中. H2驱动程序应显示为蓝色 检查列表.

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.

选择目标驱动程序(PostgreSQL,MySQL),然后 做同样的事情,例如对于PostgreSQL,指定到的完整路径 额外类路径中的"postgresql-9.4-1201.jdbc41.jar".

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.

转到别名",然后在H2上单击"+":配置JDBC链,例如,复制/粘贴启动H2时获得的jdbc链,并对目标数据库执行相同的操作:单击"+",配置并测试".

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".

当您双击别名时,您应该在新选项卡中看到数据库中的所有内容.转到源数据库中的表,对所有表进行多次选择,然后右键单击:复制表".

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".

从Alias转到目标数据库,然后执行粘贴表".完全复制所有表时,也会生成外键引用.

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.

检查您的主键:从H2到PostgreSQL,我失去了主键约束和自动递增功能. 您也可以通过右键单击重构"来重命名列和表.我使用它通过禁用名称检查选项来在完全复制后重命名保留字列.

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.

这对我来说很好.

这篇关于如何将H2Database数据库文件转换为MySQL数据库.sql文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆