最好的独立于数据库的 SQL DDL 实用程序?
我正在开发 .net 平台的项目,并希望支持多种数据库类型。 我想以通用格式将 DDL 保留在源代码控制之下,然后将其转换为数据库特定的 DDL 进行部署。
因此,我正在寻找能够将通用 DDL 转换为数据库特定 DDL 的实用程序。 理想情况下,它将支持 MSSQL 05/08、MySQL、Oracle、Postgres 和 SQL Server。 DB2 开箱即用。
以下是我迄今为止找到的工具:
- XML 到 DDL
- 没有内置的 MSSQL 支持。
- DdlUtils
- 没有命令行实用程序。 必须从 java 或 ant 脚本调用。
- 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:
- XML to DDL
- No built in support for MSSQL.
- DdlUtils
- No command line utility. Must be called from java or ant scripts.
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
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).
我已经用 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.
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
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.
据我所知,唯一支持 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.
我已成功使用 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...
我相信 Liquibase 会做你想要的,并且还会随着时间的推移管理数据库更改。
I believe that Liquibase will do what you want, and will also manage database changes over time.
您的应用程序完全与数据库无关是必须具备的功能吗? 相信您需要投入这么多工作来支持这么多数据库,这似乎有些夸张。 最重要的是,您的数据层将变得极其复杂,因为每个 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.
您可能会成功获得表及其关系的抽象表示 - 但如何处理视图、存储过程、触发器等?
You may succeed in getting an abstract representation of tables and their relationships - but how do you deal with views, stored procedures, triggers etc?