简体   繁体   中英

oracle sql to db2 sql

I have to change an Oracle SQL DDL to use it in 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. 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:

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');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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