将 MS SQL 脚本转换为 Mysql 和 Oracle

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1389759/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 18:56:48  来源:igfitidea点击:

Convert MS SQL script to Mysql and Oracle

sqlmysqlsql-serveroracle

提问by user169743

One of the applications I develop gets installed locally on the customer's site. This means that we have to support MySQL, MSSQL and Oracle as not all the customers use the same database engine.

我开发的应用程序之一在客户站点本地安装。这意味着我们必须支持 MySQL、MSSQL 和 Oracle,因为并非所有客户都使用相同的数据库引擎。

I'm writing a patch for the application, part of which involves executing a 5000 line sql script to make modifications to the database. The script is written using MSSQL syntax, however I was wondering if there is an application for automatically converting MSSQL syntax to that of Oracle and/or MySQL to save me from having to manually do it.

我正在为应用程序编写补丁,其中一部分涉及执行 5000 行 sql 脚本来修改数据库。该脚本是使用 MSSQL 语法编写的,但是我想知道是否有一个应用程序可以将 MSSQL 语法自动转换为 Oracle 和/或 MySQL 的语法,以免我不得不手动执行此操作。

回答by VulfCompressor

This is an old topic, but i would recommend using the following tool: http://www.sqlines.com/online. I had a good experience using it. No problems found since 3 months ago (when i've started using it).

这是一个老话题,但我建议使用以下工具:http: //www.sqlines.com/online。我有很好的使用体验。自 3 个月前(当我开始使用它时)以来没有发现任何问题。

回答by Adam Hawkes

For conversion to Oracle you can try the Migration Workbench.

要转换到 Oracle,您可以尝试迁移工作台

回答by Chris Gill

And even more concerning is that the databases support different locking mechanisms, so you may be able to get some tables and indexes in there, but you might introduce some issues that are very difficult to debug/replicate when you expose it into the wild.

更令人担忧的是,数据库支持不同的锁定机制,因此您可以在其中获取一些表和索引,但是当您将其公开时,您可能会引入一些很难调试/复制的问题。

You need as 3 experts to sort that lot out - one each of SQL Server, MySQL and Oracle. That or your database needs to run with a maximum of one user, with poor performance and very average database mechanisms.

您需要 3 位专家来整理这些批次 - SQL Server、MySQL 和 Oracle 各一个。那或者你的数据库需要最多一个用户运行,性能很差,数据库机制非常普通。

Sorry...

对不起...

回答by Will Marcouiller

I don't know of a database engine programming syntax converter. However, since you're working on a multi-database platform, I would consider using Enterprise Library and its application block. This will save you headaches, you got to trust me!

我不知道数据库引擎编程语法转换器。但是,由于您在多数据库平台上工作,我会考虑使用 Enterprise Library 及其应用程序块。这将免除您的头痛,您必须相信我!

I am aware that you parhaps don't have enough time for your coming releases so you will have to setup the scripts manually, but do yourself a favour, and consider using Microsoft Enterprise Library.

我知道您可能没有足够的时间来处理即将发布的版本,因此您必须手动设置脚本,但请帮自己一个忙,并考虑使用 Microsoft Enterprise Library。

Another possible way is to bring these engines as close as possible to each other in ressemblance so that you may work more conveniently with the three of them. Thus, it requires you to analyze and to decide what function should be created where and why? This is hard work, seriously.

另一种可能的方法是让这些引擎尽可能彼此接近,使其具有相似性,以便您可以更方便地使用它们三个。因此,它需要您分析并决定应该在何处以及为什么创建什么功能?这是一项艰苦的工作,认真的。

In my own experience, I no longer develop without Enterprise Library, at least the Data Application block (DAAB).

以我自己的经验,我不再在没有 Enterprise Library 的情况下进行开发,至少没有数据应用程序块 (DAAB)。

Here the link:

这里的链接:

  1. http://www.microsoft.com/downloads/details.aspx?FamilyId=1643758B-2986-47F7-B529-3E41584B6CE5&displaylang=en
  2. http://www.codeplex.com/entlib
  1. http://www.microsoft.com/downloads/details.aspx?FamilyId=1643758B-2986-47F7-B529-3E41584B6CE5&displaylang=en
  2. http://www.codeplex.com/entlib

Let me know if this helped you. If you need further assistance for setting up your Data Access layer with Enterprise Library, let me know.

如果这对您有帮助,请告诉我。如果您在使用 Enterprise Library 设置数据访问层时需要进一步帮助,请告诉我。

EDIT 2015.01.16

编辑 2015.01.16

Another best approach these days is the use of either NHibernate, Entity Frameworkor other ORM tools such as these.

现在另一个最好的方法是使用NHibernateEntity Framework或其他 ORM 工具,例如这些。

With them, no longer need any SQL scripts, all is generated for you in depending on your RDBMS configuration.

有了它们,不再需要任何 SQL 脚本,一切都根据您的 RDBMS 配置为您生成。

回答by Quassnoi

I'm writing a patch for the application, part of which involves executing a 5000line sql script to make modifications to the database. The script is written using MSSQLsyntax, however I was wondering if there is an application to automatically converting MSSQLsyntax to that of Oracleand/or MySQLto save me having to manually do it.

我正在为应用程序编写补丁,其中一部分涉及执行5000一行 sql 脚本来修改数据库。该脚本是使用MSSQL语法编写的,但是我想知道是否有应用程序可以将MSSQL语法自动转换为Oracle和/或MySQL让我不必手动执行。

It's hardly possible.

这几乎不可能。

The common subset of SQLall these systems support is quite little.

SQL所有这些系统支持的公共子集非常少。

Since you have 5000lines of code in your script, most probably it's out of this subset.

由于您5000的脚本中有几行代码,很可能它不在这个子集中。

The worst part is that it's usually not only the syntax differences, but rather major conceptual ones.

最糟糕的是,它通常不仅是语法上的差异,而且是主要的概念上的差异。

  • Oracle, for instance, supports MERGEstatement which allows inserting, deleting and updating in a single query.

    Neither SQL Server 2005nor MySQLsupport one.

  • MySQLsupports deleting from several tables at once: not available in Oracleor SQL Server.

  • SQL Server, unlike Oracleand MySQL, can update CTE's that use analytic functions.

  • Oracle例如,支持MERGE允许在单个查询中插入、删除和更新的语句。

    既不支持SQL Server 2005也不MySQL支持。

  • MySQL支持一次从多个表中删除:在Oracle或 中不可用SQL Server

  • SQL Server,与Oracle和不同MySQL,可以更新CTE使用解析函数的 。