mysql转储到derby

发布于 2024-09-19 10:02:07 字数 124 浏览 3 评论 0原文

我在 eclipse 中使用 derby 进行开发。是否可以从 MySQL 转储表并以某种方式将其用于 derby?我知道 ddl & dml 对于两个 dbms 来说都是不同的,但我正在寻找一种除了转储/导出之外的合适方法。

I'm using derby for development in eclipse. Is it possible to dump a table from MySQL and use it for derby in some way? I know that ddl & dml are different for both dbms but I'm looking for a way, other than dump/export, that would be appropriate.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

撩人痒 2024-09-26 10:02:08

我可以找到两种选择;如果我正确理解你的问题,我认为至少有一个可以涵盖你正在寻找的内容。

如果您的重点是单个表中的数据(或其子集),请使用 ij,如 Derby 工具文档(请参阅“使用批量导入和导出过程”)。可以使用所需格式的内部格式化命令从 MySQL 中提取数据,这似乎是非常标准的 CSV(这需要您的 Derby 数据库中已有一个适当的表)。

以下是来自 MySQL 论坛的示例:

SELECT a,b,a+b INTO OUTFILE '/tmp/result.text'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table; 

如果您想导入所有内容,Apache DdlUtils 将允许传输从 MySQL 到 Derby 的整个模式。这不需要在 Derby 中重复表定义,因为它会作为 DdlUtils 导入/导出过程的一部分出现。

There are two options I can find; if I understand your question correctly, I think at least one will cover what you are looking for.

If your focus is the data (or a subset thereof) from a single table, use ij as indicated in the Derby tools documentation (see "Using the bulk import and export procedures"). The data can be extracted from MySQL using intrinsic formatting commands in the required format, which appears to be pretty standard CSV (this would require that you have an appropriate table already existing in your Derby database).

Here's an example from the MySQL forums:

SELECT a,b,a+b INTO OUTFILE '/tmp/result.text'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table; 

If you want to import everything, Apache DdlUtils will allow the transfer of an entire schema from MySQL to Derby. This would not require the repeated table definition in Derby, as it would come across as part of the import/export process with DdlUtils.

心碎的声音 2024-09-26 10:02:08

除非您需要自动化该过程,否则“SQuirreL SQL 客户端的 DBCopy 插件”工具可能适合您。可能还有其他工具,但这是我所知道的工具(但我自己从未使用过)。

如果您确实需要自动化该过程,并且您不太关心 DDL,那么我可能会使用 CSV。

Unless you need to automate the process, the "DBCopy Plugin for SQuirreL SQL Client" tool might work for you. There are probably other tools, but that's the one I know (however never used myself).

If you do need to automate the process, and if you don't care so much about the DDL, then I would probably use CSV.

小镇女孩 2024-09-26 10:02:08

为了将数据从MySQL(生产环境)接管到Derby(开发环境),我使用以下命令:

mysqldump -u root -h 127.0.0.1 --compatible=ansi --complete-insert --skip-add-drop-table --skip-add-locks --skip-comments --skip-disable-keys --skip-set-charset --no-create-info dbname > export.sql

但特别是在Derby中,我还遇到了解除约束的问题。因此,插入语句必须按正确的顺序!

To take over the data from MySQL (production environment) to Derby (development environment), I use following command:

mysqldump -u root -h 127.0.0.1 --compatible=ansi --complete-insert --skip-add-drop-table --skip-add-locks --skip-comments --skip-disable-keys --skip-set-charset --no-create-info dbname > export.sql

But specially in Derby, I have also the problem of disalbing constraints. Therefore, the insert statements have to be in the correct order!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文