oracle sql to db2 sql Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of oracle sql to db2 sql without wasting too much if your time.

The question is published on by Tutorial Guruji team.

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.

Answer

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');
We are here to answer your question about oracle sql to db2 sql - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji