DB2 z/OS - 为现有 table table 创建 table 别名/同义词,指向其他现有 table

DB2 z/OS - create table alias / synonym for existing table table, pointing to other existing table

是否可以为现有的 table 创建别名或同义词以指向其他一些现有的 table?

情况:我有一个基于 Java 和 Hibernate 的工具,我的任务是从旧数据库 table 迁移一些区域(SchemaOLD.TableOLD) 到一个新的 table (SchemaNEW.TableNEW)(所有这些都发生在同一个数据库服务器中)。 DONE 已经很接近了,但我发现了一些遗留的第 3 方组件仍然指向原始位置 (SchemaOLD.TableOLD)。由于一些业务限制,我不得不寻找更快的替代解决方案(而不是让其他组件也迁移......)。

我需要以某种方式使数据库服务器 "resolve" SchemaOLD.TableOLD 字符串成为新字符串 SchemaNEW.TableNEW ,以便那些遗留组件在实际从新位置检索数据时不会受到干扰 运行。我需要这样做 ,而新旧 table 仍然存在于 DB .

这有可能吗? 什么是最好的解决方案,别名或同义词?这两者之间的区别对我来说有点不清楚...

谢谢。

如果您想使用 ALIAS or SYNONYM,那么您应该使用 ALIAS。这是来自 SYNONYM 知识中心页面的注释:

Important: Use aliases instead of synonyms. Synonyms are similar to aliases, but are supported only for compatibility with previous releases. Synonyms might not be available in future releases of DB2®. Synonyms behave differently with DB2 for z/OS® than with the other DB2 family products. Do not use synonyms when writing new SQL statements or when creating portable applications.

另一个选项可以是 VIEW:

CREATE VIEW SchemaOLD.TableOLD AS
    SELECT * FROM SchemaNEW.TableNEW

如果您还需要防止旧实用程序更新 "new" table,您可能会考虑在该视图上使用 trigger