Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2010
    Posts
    4

    Talking Unanswered: Convert sql code to Db2

    Hi,

    Please i need help to convert my Oracle bases in Db2 .
    I want one little example , because all the database is the same.

    Code SQL:

    CREATE TABLE MATRIZAVALIACAORISCORESIDUAL(
    ID INTEGER NOT NULL,
    TITULO varchar2(750) NULL,
    REMOVIDO varchar2(1) NULL,
    CONSTRAINT PKMATRIZAVALIACAORISCORESIDUAL PRIMARY KEY (ID)
    );



    My code DB2

    create table dddd
    (ID SMALLINT NOT NULL,
    TITULO VARCHAR(250),
    REMOVIDO VARCHAR(1),
    PRIMARY KEY (ID) )

    Its works, but don't declare the constraint.
    Please, i need to declare this constraint.

    Thank you

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Code:
    create table dddd
    (ID SMALLINT NOT NULL PRIMARY KEY ,
    TITULO VARCHAR(250),
    REMOVIDO VARCHAR(1))

  3. #3
    Join Date
    Nov 2010
    Posts
    4
    THKS.. solves the primary key problem , but
    I need the name of Primary_Key Constraint to log efects.

    Thks

  4. #4
    Join Date
    Jan 2010
    Posts
    335
    Quote Originally Posted by vega! View Post
    REMOVIDO VARCHAR(1),


    alter table TABNAME add constraint PK_NAME primary key (id)

  5. #5
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by vega! View Post
    THKS.. solves the primary key problem , but
    I need the name of Primary_Key Constraint to log efects.
    Which DB2 version are you working with?

    Code:
    CREATE TABLE MATRIZAVALIACAORISCORESIDUAL(
    ID INTEGER NOT NULL,
    TITULO varchar2(750) ,
    REMOVIDO varchar2(1) ,
    CONSTRAINT PKMATRIZAVALIACAORISCORESIDUAL PRIMARY KEY (ID)
    );
    The above works for me. You only need to remove the NULL default declarations, because they don't make sense anyway.

    It might be a good idea for you to start reading the DB2 manuals. http://publib.boulder.ibm.com/infoce...v9r7/index.jsp

  6. #6
    Join Date
    Nov 2010
    Posts
    4
    Quote Originally Posted by n_i View Post
    Which DB2 version are you working with?

    Code:
    CREATE TABLE MATRIZAVALIACAORISCORESIDUAL(
    ID INTEGER NOT NULL,
    TITULO varchar2(750) ,
    REMOVIDO varchar2(1) ,
    CONSTRAINT PKMATRIZAVALIACAORISCORESIDUAL PRIMARY KEY (ID)
    );
    The above works for me. You only need to remove the NULL default declarations, because they don't make sense anyway.

    It might be a good idea for you to start reading the DB2 manuals. IBM DB2 9.7 for Linux, UNIX and Windows Information Center
    Thks.. solve the problem.
    I don't put the codom.
    Thanks

  7. #7
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Quote Originally Posted by n_i View Post
    You only need to remove the NULL default declarations, because they don't make sense anyway.[
    The NULL default declarations don't hurt anything and make things explicit. If this is preferred, just leave them be.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  8. #8
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    This is why I asked about the DB2 version - explicit declarations of NULL column defaults were not supported until 9.7 fp2 I think.

  9. #9
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Yeah, right...
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •