Oracle DB (PL/SQL) 重构工具

发布于 2024-08-06 13:18:20 字数 704 浏览 2 评论 0原文

我想知道是否有任何好的 Oracle 数据库重构工具,特别是 PL/SQL 重构工具。我正在开发一个项目,其中一半开发人员使用 c#,另一半开发人员使用数据库,其中有一个大型且复杂的模式以及 pl/sql 中的大型代码库。我们也使用 sql server,但数据库团队只使用 Oracle。

这个代码库正在积极开发并逐渐重构,但我很惊讶地看到 Oracle 的重构工具看起来有多糟糕(或者至少与 Eclipse 和 Resharper 相比)。

开发人员使用的 Toad 仅具有基本的重构支持(可能是因为它似乎更针对数据库管理而不是开发)。我以前自己使用过 Toad,但一直认为 pl/sql 有更多用于处理代码的功能,但从未研究过它。现在据我所知,它提供的唯一重构是提取方法(过程)和变量重命名。我读了一篇比较 sql Developer 和 pl/sql Developer 的文章,这些似乎对重构没有更好的支持。我快速浏览了 eclipse 数据工具项目,但没有看到自从我上次使用它(几年前)以来他们添加了重构支持。

对于 Sql Server,存在 Sql Refactor,当表结构更改时,它会传播到存储过程。对我来说,这比让某人手动更新所有存储过程更干净且不易出错。我过去在一个项目中使用过这些工具的旧版本,它们似乎还不错,但有点慢,但那是几年前的事了,它仍然可用。

对于 Oracle 来说,类似的东西已经对我们的开发团队有很大帮助,所以如果 Oracle 确实存在一些好的重构工具,我会很感激。 谢谢, 克罗克德

I was wondering if there are any good refactoring tools for Oracle databases and especially for PL/SQL. I'm working on a project where half the developers are working with c# and the other half on the db where there is a large and complex schema and a large code base in pl/sql. We also use sql server but the database team work exclusively with Oracle.

This code base is being worked on actively and is being refactored gradually but I was quite surprised to see how bad the refactoring tools for oracle seem to be (or at least in comparison to Eclipse and Resharper).

The developers are using Toad which only has basic refactoring support (probably as its seems to be targeted more towards db admin then development). I've used Toad myself before but always had assumed for pl/sql there were more features for working with code but had never looked into it. Now as far as I can see the only refactorings that it provides are extract method (procedure) and variable renaming. I read an article comparing sql developer and pl/sql developer and these do not appear to have any better support for refactoring. I had a quick look at the eclipse data tools project but couldn't see that they've added refactoring support since I last used it (a few years ago).

For Sql Server there exists Sql Refactor which when table structures are changed gets propagated through to the stored procedures. This for me is much cleaner and less error prone than having someone manually update all stored procedures. I used an older version of these tools on a project in the past and they seemed to be quite ok but a bit slow but that was a few years ago and it was still usable.

Something similar for Oracle would already be a big help for our developement team so I'd appreciate some pointers to good refactoring tools for Oracle if they do exist.
Thanks,
Crocked

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

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

发布评论

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

评论(1

温馨耳语 2024-08-13 13:18:20

碰巧,TOAD 中的“D”代表的是“Developer”(开发者),而不是“DBA”(DBA)。事实上,许多 DBA 厌恶 TOAD 和其他此类工具。

你运气不好。据我所知,还没有重构 PL/SQL 的工具。根本问题在于,重构作为一个概念来自于OOP范式,而PL/SQL不是面向对象的。它不支持继承或多态(*)。这意味着许多支持经典重构实践的技术(如 Fowler 定义的)——抽象、接口等——在 PL/SQL 中没有类似的技术。

由此推论,习惯于将重构作为其概念工具箱一部分的人们往往会避免使用 PL/SQL 进行编程。我曾经为此在TDD清单上进行过激烈的争论。结果是,即使是需要并欣赏 PL/SQL 优点的开发人员也宁愿使用具有更好工具支持的语言进行开发,敏捷宣言尽管如此。

重构最重要的工具是自动化单元测试。尽管 TOAD 没有(我认为)集成单元测试,但 Oracle SQL Developer 的下一版本将会。还有独立的单元测试工具。我最近在 另一个 SO 线程

在重构 PL/SQL 以匹配数据库中的更改方面,可以说大多数与表的交互应该由生成的表 API 进行,而不是嵌入到事务性 PL/SQL 中。在这个快乐的境界中,不需要重构工具,我们只需要重新生成相关的 API 即可。我上面链接的帖子也提到了 QCGU,这是一个可以做到这一点的工具。当然,当我们的 PL/SQL 代码库不是以这种方式组织时,生活就会变得更加困难。您不会感到惊讶的是,没有太多工具支持在 PL/SQL 中实现 Feathers 的 WELC。

(*) 是的,我知道 Oracle 有类型,但它们是 (a) SQL 而不是 PL/SQL,以及 (b) 有多少人实际上使用它们构建 API?

As it happens the "D" in TOAD stands Developer not DBA. In fact many DBAs anathematise TOAD and other such tools.

You are out of luck. As far as I know there are no tools for refactoring PL/SQL. The root problem is that refactoring as a concept comes from the OOP paradigm, and PL/SQL is not object oriented. It does not support inheritance or polymorphism (*). This means that many of the techniques which underpin classical refactoring practice (say as defined by Fowler) - abstraction, interfaces, etc - have no analogue in PL/SQL.

The corollary of this is that people who are used to having refactoring as part of their conceptual toolbox tend to avoid programming with PL/SQL. I once got into a heated debate on the TDD list over this. The upshot being that even developers who need and appreciated the virtues of PL/SQL would rather develop in languages with better tool support, clause #1 of the Agile Manifesto notwithstanding.

The most important tool for refactoring is automated unit testing. Although TOAD does not (I think) have integrated unit testing, the next release of Oracle SQL Developer will. There are also standalone unit test tools. I recently mentioned a couple of them in another SO thread.

In terms of refactoring PL/SQL to match changes in the database, arguably most interaction with tables ought to be underaqtken by generated table APIs rather than being embedded in transactional PL/SQL. In this happy realm there is no need for refactoring tools, we just need to re-generate the relevant APIs. The post I linked to above also mentions QCGU, a tool which can do this. Of course, when we have a PL/SQL codebase which isn't organised in such a fashion then life is harder. You won't be surprised to learn that there isn't a lot of tool support for implementing Feathers's WELC in PL/SQL.

(*) Yes, I know Oracle has Types but they are (a) SQL not PL/SQL and (b) how many people out there are actually building APIs using them?

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