将数据从一个数据库移动到具有不同数据结构的另一个数据库

发布于 2024-08-07 15:39:03 字数 278 浏览 2 评论 0原文

如何将数据从假设的mysql数据库移动到postgres数据库?

场景:两个类似的应用程序。用户想要从一个应用程序切换到另一个应用程序。 但他在之前使用 mysql 数据库的应用程序中保留了某些数据信息。当他切换应用程序时,他必须将数据从旧应用程序移动到使用 postgres 的新应用程序。

这两个数据库都有不同的结构、表与表的关系、表的数量以及表下的列。

但如何将日期从一个数据库移动到另一个数据库呢?

有什么工具可以做到这一点吗?如果是这样,任何人都可以建议这样的工具..

How to move data from suppose mysql database to postgres database?

Scenario: Two similar application. A user wants to switch from one application to other.
But he had maintained certain data information in his previous appilaction which uses mysql database.When he switch his appliaction he has to move his data from his old application to new application which uses postgres.

Both database are different with different structure and table and table relationships, Number of tables and also columns under them.

But how to move the date from one database to other?

Is there any tool to do this? If so can anyone suggest such tool..

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

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

发布评论

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

评论(6

水水月牙 2024-08-14 15:39:03

它可能不是您所需要的,但是此页面包含一个

“可下载的Magic drupal-mysql2pgsql.txt”。 pl 脚本”

并讨论了迁移数据的困难。

这可能不合适,因为它可能只迁移 Drupal 数据库(并且您没有说明涉及哪些应用程序)。

您最好的选择可能是以简单的文本形式导出/备份 MySQL 数据,该文本形式可以被处理为 PostgreSQL 格式并导入。这需要一些脚本编写/编辑。

当然,这就是您需要一个工具来完成这项工作的原因。

It may not be what you require, but this page includes a

"downloadable Magic drupal-mysql2pgsql.pl Script"

and a discussion of the difficulties of migrating the data.

It may be inappropriate because it may only migrate Drupal databases (and you didn't say which applications are involved)

Your best bet may be to export/backup your MySQL data in a simple text form which can be massaged into PostgreSQL format and imported. This would require some scripting/editing.

Which, of course, is why you asked for a tool for the job.

南…巷孤猫 2024-08-14 15:39:03

我会这样做:(

仅使用数据库工具)

  • 在 MySQL 中创建一个新数据库并用空表填充它,关系与我需要迁移到的关系完全一样(postgres)
  • 将数据从原始 MySQL 数据库复制到新数据库使用 SELECT 语句(因为我认为新表是旧表的混合),或者可能是一些存储过程...
  • 然后使用转储工具为我的新数据库生成 sql 脚本来创建别处。对于 MySQL,该工具是 mysqldump 它有一个选项来生成 postgres 兼容脚本:--兼容=postgres 和许多其他非常有趣的选项。
  • 在我的新数据库上运行这些脚本
  • 检查不一致之处,纠正...

(使用定制的应用程序+ORM(例如:C#,NHibernate)——实施时间更长):

  • 在我的新DBMS上创建我的新数据库
  • 创建一个OR映射对于原始数据库,
  • 为新数据库创建一个 OR 映射,
  • 使用我的 ORM 导入原始数据
  • ,转换我的数据以适应我的新数据库&用我的 ORM 插入它

(使用已知的工具):

抱歉,但我不知道是否有一个工具可以做到这一点!

I would do it like this:

(Using only database tools)

  • create a new database in MySQL and populate it with empty tables, relations exactly like the one I need to migrate to (postgres)
  • copy data from the original MySQL database to the new one using SELECT statements (as new tables are a mix of the old onew I suppose), or may be some stored procedures...
  • then use a dumping tool that will generate sql scripts for my new database to create elsewhere. For MySQL the tool is mysqldump and it has an option to generate postgres compatible scripts:--compatible=postgres and many other very interesting options.
  • run those scripts on my new database
  • check for inconsistencies, correct...

(Using a custom made application+ORM (ex: C#, NHibernate) -- more longer to implement):

  • create my new database on my new DBMS
  • create a O-R mapping for the original database
  • create a O-R mapping for the new database
  • import original data using my ORM
  • transform my data to fit into my new database & insert it with my ORM

(Using a known tool):

Sorry, but I have no idea if there is a tool that can do this!

平定天下 2024-08-14 15:39:03

您描述的问题是数据仓库世界中最常见的问题之一,您需要从应用程序数据库(通常是经典的关系数据模型)中获取数据,并在具有不同结构的数据仓库中进行合并和集中(大多数情况下具有维度)数据模型)。这就是 ETL 作业(提取、转换、加载)的作用。

您可以将它们作为 SQL 脚本,手动或自动运行。您需要建立的是转换逻辑,然后将其实现为 SQL 脚本。

有专用的 ETL 工具,但我认为它们不会为您的案例增加太多价值。

The problem you're describing is one of the most common problems in datawarehouse world, where you need to take data from application databases (usually classic relational data model) and consolidate and centralize in a datawarehouse with different structure (most of the time with dimensional data model). That what ETL jobs (Extract Transform Load) do.

You can have them as SQL scripts, run by hand, or automatically. What you need to establish is the transformation logic, then to implement it as SQL scripts.

There are dedicated ETL tools, but I don't think they add too much value in your case.

岁月流歌 2024-08-14 15:39:03

我还建议使用 ETL 工具来完成此类工作。应用不同的功能将使您的迁移100%成功。我建议商业用户使用 Apatar (apatar.com) 等开源工具,而技术用户则使用 Talend (talend.com)。

I would also advise using ETL tools for this kind of job. Applying different functions will make your migration 100% successful. I recommend using open source tools like Apatar (apatar.com) for business users and Talend (talend.com) for technical users.

辞慾 2024-08-14 15:39:03

针对这些场景有一整套工具。谷歌搜索“ETL”,可能还有您正在处理的数据库供应商名称,您可能会找到比您在合理时间内评估的更多解决方案。

There is a whole industry of tools for these scenarios. Google for "ETL" and probably also the database vendor names you are dealing with and you will likely find more solutions than you can evaluate in a reasonable amount of time.

讽刺将军 2024-08-14 15:39:03

我建议采用与其他路径相同的路径,但略有不同。使用 ETL 工具来做到这一点。大多数 ETL 工具都可以完成您刚才描述的工作。如果您不想花任何钱购买“ETL”工具,我会将票投给 Talend 开源 ETL 工具。我用过它并且它非常强大。文档和示例可在 http://www.talend.com 中找到。

I would suggest the same path as the others with a slight difference. Use ETL tool to do that. Most of the ETL tools would do the job you just described. If you don't want to spend any money buying an "ETL" tool, my vote goes to Talend Open Source ETL tool. I've used it and it is pretty powerful. Documentation and examples are available in http://www.talend.com.

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