开发针对多个数据库的应用程序时如何维护 SQL 脚本
想象一个应该与不同数据库供应商合作的应用程序。众所周知,SQL 的语法(尤其是 DDL)是不可移植的。您如何处理维护 SQL 脚本?
到目前为止,我看到三个选项:
以其中一个数据库的格式存储 SQL,并拥有一个自动从一种语法转换为另一种语法的工具(您知道吗?这样的工具?)
以某种人工语言存储 SQL,并有一个能够生成按需供应商特定的 SQL(这里有什么建议吗?)
以多种数据库格式存储 SQL,忽略冗余(这是最糟糕的一种,不是吗?)不是吗?)
你有推荐的吗?你有更好的主意吗?
开发环境试图遵循持续集成原则,因此自动化是这里的一个关键特性。
Imagine an application which is supposed to work with different database vendors. As we all know the syntax for SQLs (especially DDL) is not portable. How do you deal with maintaing the SQL scripts?
Until now I see three options:
to store SQLs in format of one of the databases and have a tool which automatically converts from one syntax do another (do you know such tools?)
to store SQLs in some artificial language and a have a tool which is able to generate vendor-specific SQLs on demand (any recommendation here?)
to store SQLs in many database formats neglecting the redundancy (this is the worst one, isn't it?)
Do you recommend any of them? Do you have a better idea?
The development environment tries to follow the continuous integration principles, so automation is a key feature here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看看 Liquibase(这基本上是列表中的第二项)
http://www.liquibase.org
它是不完美(例如它不支持检查约束)但它非常有用
Have a look at Liquibase (that's essentially your second item on the list)
http://www.liquibase.org
It's not perfect (e.g. it does not support check constraints) but it is quite useful
该视频展示了使用 Subsonic 项目 http://subsonicproject.com/docs/Using_SimpleRepository 及其数据的解决方案迁移能力。策略是使用通用语言并将其应用于不同的数据库。
希望这就是您正在寻找的
This video shows a solution using the Subsonic project http://subsonicproject.com/docs/Using_SimpleRepository and its data migration capabilities. The strategy is to use a general language and apply it to different databases.
Hope this is what you were looking for
使用某种具有模式生成功能的 ORM 框架。
Use some kind of ORM framework with schema generation capability.