DB2 中的唯一索引
我正在将一些 SQL 查询从 Oracle 迁移到 DB2 UDB 8。
以下是 SQL 查询:
create unique index ACT_UNIQ_RU_BUS_KEY on ACT_RU_EXECUTION
(case when BUSINESS_KEY_ is null then null else PROC_DEF_ID_ end,
case when BUSINESS_KEY_ is null then null else BUSINESS_KEY_ end);
有人知道 DB2 UDB 8.x 中的等效 SQL 是什么吗?
仅供参考:这是我为 Activiti BPM 工具创建的 SQL 查询。
I am migrating some SQL queries from Oracle to DB2 UDB 8.
Here is the SQL query:
create unique index ACT_UNIQ_RU_BUS_KEY on ACT_RU_EXECUTION
(case when BUSINESS_KEY_ is null then null else PROC_DEF_ID_ end,
case when BUSINESS_KEY_ is null then null else BUSINESS_KEY_ end);
Does anybody know what could be a equivalent SQL in DB2 UDB 8.x?
FYI: This is an SQL query I am creating for Activiti BPM tool.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这似乎是一种构建索引的复杂方法,并且第三行看起来非常类似于只编写
BUSINESS_KEY_
。假设PROC_DEF_ID_
和BUSINESS_KEY_
是列名称,那么索引似乎按该顺序位于这两列上,但如果BUSINESS_KEY_
为 null,则索引中的第一列也被视为 null。据我所知,在 DB2 中没有办法做到这一点 - 至少在 8.x 版本中没有。 DB2 LUW 9.7 手册页 CREATE INDEX 没有提及任何等效内容。
That seems to be a complicated way to build an index, and the third line looks remarkably as if it is equivalent to writing just
BUSINESS_KEY_
. Assuming thatPROC_DEF_ID_
andBUSINESS_KEY_
are column names, then the index seems to be on those two columns in that sequence, with the twist that ifBUSINESS_KEY_
is null, then the first column in the index is also treated as null.There isn't a way to do that in DB2, as far as I know - at least, not in the 8.x versions. The DB2 LUW 9.7 manual page for CREATE INDEX does not mention anything equivalent.