最好的独立于数据库的 SQL DDL 实用程序?

发布于 2024-07-11 09:33:38 字数 742 浏览 5 评论 0原文

我正在开发 .net 平台的项目,并希望支持多种数据库类型。 我想以通用格式将 DDL 保留在源代码控制之下,然后将其转换为数据库特定的 DDL 进行部署。

因此,我正在寻找能够将通用 DDL 转换为数据库特定 DDL 的实用程序。 理想情况下,它将支持 MSSQL 05/08、MySQL、Oracle、Postgres 和 SQL Server。 DB2 开箱即用。

以下是我迄今为止找到的工具:

  1. XML 到 DDL
    • 没有内置的 MSSQL 支持。
  2. DdlUtils
    • 没有命令行实用程序。 必须从 java 或 ant 脚本调用。
  3. ActiveRecord::Migration
    • 不支持外键
    • 不确定如何与 .net 项目集成。

有谁对我提到的或了解其他人有经验吗?

I'm working on a project for the .net platform and would like to support multiple database types. I would like to keep the DDL under source control in a generic format then convert it to database specific DDL for deployment.

So I'm looking for utilities that will convert generic DDL into database specific DDL. Ideally it would support MSSQL 05/08, MySQL, Oracle, Postgres, & DB2 out of the box.

Here are the tools that I've found so far:

  1. XML to DDL
    • No built in support for MSSQL.
  2. DdlUtils
    • No command line utility. Must be called from java or ant scripts.
  3. ActiveRecord::Migration
    • No support for foreign keys
    • Not sure how to integrate with .net project.

Does anyone have experience with those I've mentioned or know of others?

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

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

发布评论

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

评论(9

不再让梦枯萎 2024-07-18 09:33:39

DDLUtils 似乎是正确的选择。 即使该项目最近不太活跃,效果也很好。

编码很好,我没有遇到任何问题(在 MySQL、Oracle、H2DB 上工作,...)。

事实上,目前还没有内置的命令行,但是您可以从命令行启动 ant 任务,或者编写自己的命令行包装器(这实际上并不难......我是在我这边做的,实际上)。

DDLUtils seems to be the right choice. Works very well, even if the project is not really active these days.

The coding is fine, and I had no issues with it (working on MySQL, Oracle, H2DB, ...).

Indeed there is for the now no command-line built-in, but you can either launch ant tasks from command-line, or write your own command-line wrapper (it's really not so hard ... i did it on my side, in fact).

骷髅 2024-07-18 09:33:39

我已经用 DDLUtils 做了基本实验。 我尝试了 Mysql、MSSql 和 oracle,效果很好。 检查表创建、约束和索引。 拒绝使用它,因为它不活跃,并且阻止程序错误长期以来一直存在。

I have done basic experiments with DDLUtils. I tried for Mysql,MSSql and oracle ,it works fine. checked for table creation ,constraints and indexes. Refused to use it as it is not active and blocker bugs are open from long time.

摘星┃星的人 2024-07-18 09:33:39

jOOQ 可以在方言之间转换任意 SQL,而不仅仅是 DDL。 可以在此处找到相关信息的在线版本:https://www.jooq.org/translate ,以及 CLI 版本 也可用。

免责声明:我在 jOOQ 背后的公司工作

jOOQ can translate arbitrary SQL between dialects, not just DDL. An online version of what's possible can be found here: https://www.jooq.org/translate, and a CLI version is available too.

Disclaimer: I work for the company behind jOOQ

就像说晚安 2024-07-18 09:33:38

NHibernate 的 SchemaExport 工具 可以从任何 NHibernate 的 OR 映射生成适当的 DDL支持的 DBMS 方言。 然而,正如其他人所暗示的那样,如果您在该级别上工作,那么您实际上会受到 DBMS 之间相当薄的共同点的限制。

NHibernate's SchemaExport tool can generate an appropriate DDL from the OR mappings for any of NHibernate's supported DBMS dialects. However, as others have implied, if you're working at that level you're really restricted to the rather thin common denominator between DBMSes.

一江春梦 2024-07-18 09:33:38

据我所知,唯一支持 SQL Server 的是 SQLFairy。 它是用 Perl 编写的,功能非常丰富。 XML2DDL 也相当不错,但如果它不支持您选择的 DBMS,那么它就不是真正可行的。

The only one that I know of that has support for SQL Server is SQLFairy. It's written in Perl and is pretty feature rich. XML2DDL is pretty good too, but if it doesn't support your DBMS of choice it's not really viable.

惜醉颜 2024-07-18 09:33:38

我已成功使用 Ruby/Rails' Oracle 上的 ActiveRecord 迁移, SQL Server 2005、MySQL 和 SQLite。 我想我也可能设法在 Access 上使用它,但这可能是内存错误。 据我所知,它还支持 PostgreSQL 和 db2,无论是“开箱即用”还是通过额外下载。 如果你想要一些更奇特的东西并且渴望一个真正自虐的 DIY 项目,你总是可以编写自己的适配器......

它工作得很好,但你必须接受这是一个会限制你访问的概念特定于平台的功能。 不仅是 AR,而且很可能是任何不需要花费大量资金的跨平台工具:例如,如果您的目标平台不支持触发器,您会怎么做? 或者存储过程? (例如 MySQL 4.0 或 SQLite)。 任何跨平台系统都必须处理这样的问题(例如,在与一个试图在 SQL Server 查询中应用 Oracle 外连接运算符的版本进行斗争之后,我对 Crystal Reports 产生了终生的仇恨)。

如果您坚持使用表、索引和更简单的约束,我希望您可以使用各种各样的平台。 有一个论点建议您通常应该寻找在数据库之外进行进一步处理的任何内容。 我不会在这里更进一步——这是一场有点宗教性的辩论……

I've successfully used Ruby/Rails' ActiveRecord Migrations on Oracle, SQL Server 2005, MySQL and SQLite. I think I may have managed to use it on Access too, but that may a faulty memory. It also supports PostgreSQL and db2 that I know of, either "out of the box" or by additional download. And you can always write your own adapter if you want something more exotic and have a desire for a really self-flagellatory DIY project...

It works really well, but you have to accept that this is a concept that will limit your access to platform-specific features. Not just with AR, but with - in all probability - any cross-platform tool that doesn't cost bazillions: for example, what do you do if your target platform doesn't support triggers? Or stored procedures? (MySQL 4.0, for example, or SQLite). Any cross-platform system has to deal with issues like this (I acquired a lifetime hatred of Crystal Reports, for example, after wrestling with a version that tried - catastrophically - to apply an Oracle outer-join operator in a SQL Server query).

If you stick to tables, indexes and the simpler constraints, I'd expect a wide variety of platforms to be available to you. There's an argument for suggesting that you perhaps should generally be looking for anything further to be handled outside your DB. I won't go further than that here - it's a somewhat religious debate...

晨曦÷微暖 2024-07-18 09:33:38

我相信 Liquibase 会做你想要的,并且还会随着时间的推移管理数据库更改。

I believe that Liquibase will do what you want, and will also manage database changes over time.

情绪 2024-07-18 09:33:38

您的应用程序完全与数据库无关是必须具备的功能吗? 相信您需要投入这么多工作来支持这么多数据库,这似乎有些夸张。 最重要的是,您的数据层将变得极其复杂,因为每个 RDBMS 之间都存在细微的差异。

Is it a must-have feature that your application is completely database agnostic? It seems a far stretch to believe that you need to put this much work into supporting this many databases. On top of the fact your data layer is going to be incredibly complex as there are subtle differences in each RDBMS.

迷爱 2024-07-18 09:33:38

您可能会成功获得表及其关系的抽象表示 - 但如何处理视图、存储过程、触发器等?

You may succeed in getting an abstract representation of tables and their relationships - but how do you deal with views, stored procedures, triggers etc?

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