创建从旧模型到当前模型的迁移脚本(正在开发中)

发布于 2024-09-07 09:51:41 字数 327 浏览 2 评论 0原文

最初,模型(包括表、视图、包等)是根据 DML 脚本(由 TOAD 生成)构建的。脚本看起来像:

DROP TABLE TABLESPACE.TABLENAME CASCADE CONSTRAINTS;
CREATE TABLE TABLESPACE.TABLENAME
...

随着时间的推移,模​​型发生了变化 - 我向表中添加了新列,更改了一些视图,向包中添加了新方法等。

创建从旧模型到我当前拥有的状态的迁移脚本的最简单方法(软件、技术)是什么?作为迁移脚本,我需要有一组可应用于遗留模型的ALTER等,以便对其进行升级。

Originally, the model (including tables, views, packages, etc.) was built from the DML scripts (generated by TOAD). The scripts look like:

DROP TABLE TABLESPACE.TABLENAME CASCADE CONSTRAINTS;
CREATE TABLE TABLESPACE.TABLENAME
...

Over time the model has changed - I've added new columns to the tables, altered some vews, added new methods to packages, etc.

What would be the easiest way (software, technique) to create migration scripts from the old model to the state of things I currently have. As a migration script I need to have a set of ALTERs, etc. that can be applied to the legacy model, so that it will be upgraded.

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

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

发布评论

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

评论(2

夕色琉璃 2024-09-14 09:51:41

“随着时间的推移,模​​型已经发生了变化 -
我已向表中添加了新列,
改变了一些视图,添加了新方法
到包等。

最简单的方法是什么
(软件、技术)创造
从旧模型迁移脚本
事情的状态”

嗯,最简单的方法是获取您编写的所有 DDL 脚本,以从源代码管理应用这些更改,并针对您需要的任何数据库运行它们。

原因问题是因为你还没有以这种方式做事,

下一个最简单的方法是使用原始脚本(我认为你有这些)并构建一个新模式(显然不是表空间)。 。

如果您有 TOAD 的 DBA 模块,您可以使用其 Schema Diff 工具生成一个脚本,该脚本将应用所有必要的更改(如果您没有必要的许可证,您仍然可以使用 Diff) 实用程序,但不能将脚本保存为文件)市场上还有其他工具可以执行此操作:其中大多数本身就是收费产品(SQL Compare)或需要额外的许可证(Oracle 的免费 SQL Developer 提供)。此功能,但您需要获得变更管理包许可才能使用它)。

如果您有时间,一个更便宜的选择是使用数据字典生成您自己的脚本来识别更改。但这需要付出很多努力。

"Over time the model has changed -
I've added new columns to the tables,
altered some vews, added new methods
to packages, etc.

What would be the easiest way
(software, technique) to create
migration scripts from the old model
to the state of things"

Well, the easiest way of doing this would be to get all the DDL scripts you wrote to apply those changes from source control and run them against whatever database you need to.

I suppose the reason you're asking this question is because you haven't been doing things in that fashion. Tsk tsk.

The next easiest approach is to use the original scripts (I take ityou have those) and build a new schema (not the tablespaces obviously). Then compare your new schema against the modified schema to derive the differences.

If you have the DBA module for TOAD you can use its Schema Diff tool to generate a script which will apply all the necessary changes (if you dont have that requisite licence you can still use the Diff utility but you can't save the script as a file). There are other tools on the market which do this: most of them are either chargeable products in their own right (SQL Compare) or require additional licences (Oracle's free SQL Developer offers this functionality but you need to licence the Change Management Pack in order to use it).

If you have the time, a cheaper option is to generate your own scripts using the data dictionary to identify the changes. But that is a lot of effort.

仲春光 2024-09-14 09:51:41

当您说需要 UPDATE 语句时,您的意思是希望数据保持更新为新数据库中的数据吗?如果您希望数据完全匹配,那么您可以这样做,但是如果您希望将相同的逻辑应用于现有数据库以将其带到新数据库,那么您将需要保存这些更新脚本才能执行此操作那。例如,如果您因为在某处代码中发现了错误而需要增加系统中所有订单的 sales_date,则无法仅通过查看数据库来确定这一点。

要使一个数据库与另一个数据库匹配,Red Gatee 有一些很好的工具 - SQL Compare 和 SQL Data Compare 应该能够帮助你。数据比较工具只会使数据完全匹配,对于非常大的表来说效率不高。不过,这对于查找表之类的东西很有用。

还有其他类似的产品(我想到的是 SQL Examiner)。

When you say that you need UPDATE statements, do you mean that you want the data to be kept updated to what you have in your new database? If you want the data to match exactly then you can do that, but if you want the same logic applied to the existing DB to bring it up to the new DB then you will need to have saved off those UPDATE scripts to be able to do that. For example, if you needed to increment the sales_date for all orders in your system because you found a bug in the code somewhere, there is no way to determine that from just looking at a database.

To make one database match another, Red Gate has some good tools - SQL Compare and SQL Data Compare should be able to help you. The data compare tool will only make the data match exactly and isn't very efficient for extremely large tables. It's good for things like look-up tables though.

There are other similar products out there (SQL Examiner comes to mind).

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