简体   繁体   English

从oracle sql到db2 sql

[英]oracle sql to db2 sql

I have to change an Oracle SQL DDL to use it in zOS/DB2. 我必须更改Oracle SQL DDL才能在zOS / DB2中使用它。 Now I'm stuck in this part: 现在我陷入了这一部分:

 ... ATTRIBUTE1 char check (IS_FINISHED in (0,1)),
     ATTRIBUTE2 char check (HAS_ERROR in (0,1)),...

I have never used a 'check' in oracle, neither in DB2. 我从未在oracle中使用过“ check”,在DB2中也从未使用过。 Can someone please help me out here? 有人可以帮我吗? Thank You. 谢谢。

These are inline check constraints. 这些是内联检查约束。 Normally, the column names and types would match. 通常,列名和类型将匹配。 In either database, I would expect: 在这两个数据库中,我都希望:

 IS_FINISHED char(1) check (IS_FINISHED in ('0', '1')),
 HAS_ERROR char(1) check (HAS_ERROR in ('0', '1')),

If inline check constraints are not allowed in a database, then you can add them as you would other constraints: 如果数据库中不允许内联check约束,则可以像添加其他约束一样添加它们:

alter table t
    add constraint chk_t_is_finished check (IS_FINISHED in ('0', '1'),
    add constraint chk_t_has_error check (HAS_ERROR in ('0', '1');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM